pdf

Extract, merge, split, create, and fill PDF documents using Python libraries and command-line tools.

Updated Aug 25, 2017
One-click install
npx skills add https://github.com/loki495/dotfiles --skill pdf-loki495
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: pdf
Source: https://github.com/loki495/dotfiles/tree/main/ai/skills/synced/4f2cd280-c105-47f5-b498-fb931ff17906_01354434-3473-483d-87d9-0aa269eff282/pdf
Command: npx skills add https://github.com/loki495/dotfiles --skill pdf-loki495

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pypdf, pdfplumber, pdf2image, Pillow, reportlab, pytesseract, and includes scripts (resource) and references (resource) components.

What problem does it solve? Working with PDF files programmatically is fragmented across many libraries and tools, and tasks like filling forms, extracting tables, or handling scanned documents each require different approaches. This Skill consolidates PDF processing into one guide with ready-to-run scripts and decision logic for choosing the right method. ## Core Features & Use Cases - Read and Extract: Pull text, tables, metadata, and embedded images from PDFs using pypdf, pdfplumber, and poppler-utils, including OCR for scanned documents. - Modify and Create: Merge, split, rotate, watermark, encrypt, and decrypt PDFs, or generate new PDFs with reportlab. - Form Filling: Fill both fillable AcroForm fields and non-fillable forms via text annotations, with structure extraction, bounding-box validation, and visual verification scripts. - Use Case: You receive a non-fillable government form as a PDF. The Skill extracts the form structure, computes precise field coordinates, validates the bounding boxes, fills in the values, and renders the output for visual verification. ## Quick Start Use the pdf skill to merge these three PDF files into a single document and extract the text from the first page.

Frequently Asked Questions about pdf

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fill a PDF form with Python?▼

First run check_fillable_fields.py to detect AcroForm fields. For fillable PDFs, extract field info to JSON, supply values, and run fill_fillable_fields.py. For non-fillable PDFs, compute coordinates and add text annotations with fill_pdf_form_with_annotations.py.

How do I extract tables from a PDF in Python?▼

Use pdfplumber's page.extract_tables() method, which detects cell boundaries and returns rows as lists. You can convert the results to pandas DataFrames and export them to Excel or CSV for further analysis.

What is the difference between pypdf and pdfplumber?▼

pypdf handles structural operations like merging, splitting, rotating, metadata, and encryption. pdfplumber focuses on content extraction with layout awareness, making it better for text positioning and table detection.

Can I extract text from a scanned PDF?▼

Scanned PDFs contain images rather than text layers, so standard parsers return nothing. Convert pages to images with pdf2image, then run pytesseract OCR on each image to recover the text.

Why does my filled PDF form show text in the wrong position?▼

Mispositioned text usually comes from mixing coordinate systems. Structure-based fields need pdf_width/pdf_height coordinates, while visually estimated fields need image_width/image_height pixel coordinates; validate boxes with check_bounding_boxes.py before filling.

How do I merge or split PDFs from the command line?▼

Use qpdf: merge with 'qpdf --empty --pages file1.pdf file2.pdf -- merged.pdf' and split page ranges with 'qpdf input.pdf --pages . 1-5 -- out.pdf'. The pypdf library offers equivalent operations in Python.