pdf

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

Updated Oct 7, 2022
One-click install
npx skills add https://github.com/tamagusko/linux-cfg --skill pdf-tamagusko
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pdf
Source: https://github.com/tamagusko/linux-cfg/tree/main/dotfiles/claude/skills/pdf
Command: npx skills add https://github.com/tamagusko/linux-cfg --skill pdf-tamagusko

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pypdf, pdfplumber, pdf2image, Pillow, pytesseract, reportlab, pypdfium2, 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 OCR on scanned documents each require different approaches. This Skill consolidates PDF operations into one guide with ready-to-use code and scripts. ## Core Features & Use Cases - PDF Manipulation: Merge, split, rotate, encrypt, decrypt, watermark, and extract images or metadata using pypdf, qpdf, and poppler-utils. - Text and Table Extraction: Pull text and structured tables with pdfplumber, and run OCR on scanned PDFs with pytesseract and pdf2image. - PDF Creation: Generate new PDFs with reportlab, including multi-page reports with styled tables. - Form Filling: Fill both fillable AcroForm fields and non-fillable forms via text annotations, with scripts for field extraction, bounding-box validation, and coordinate conversion. - Use Case: Given a stack of scanned intake forms, convert them to images, determine field coordinates, validate bounding boxes, and produce filled PDFs automatically. ## Quick Start Use the pdf skill to merge the three attached PDF reports into a single document and extract the tables from page two.

Frequently Asked Questions about pdf

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

FAQPage Schema
How do I merge multiple PDF files in Python?

Use pypdf's PdfWriter to merge PDFs by adding each page from the source files with add_page, then write the result to a new file. Alternatively, run qpdf --empty --pages file1.pdf file2.pdf -- merged.pdf from the command line.

How do I extract tables from a PDF with pdfplumber?

Open the PDF with pdfplumber and call page.extract_tables() on each page to get table data as lists of rows. You can load the results into pandas DataFrames and export them to Excel or CSV for analysis.

How do I fill a PDF form that has no fillable fields?

Extract the form structure with the extract_form_structure.py script to get label and checkbox coordinates, build a fields.json with entry bounding boxes, validate it with check_bounding_boxes.py, then fill it using fill_pdf_form_with_annotations.py, which adds text annotations at the specified positions.

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 and run OCR with pytesseract to produce searchable text.

Why do subscript characters render as black boxes in reportlab PDFs?

ReportLab's built-in fonts lack Unicode subscript and superscript glyphs, so characters like ₀ render as solid boxes. Use the <sub> and <super> XML tags inside Paragraph objects instead.

How do I remove a password from an encrypted PDF?

Run qpdf --password=yourpassword --decrypt encrypted.pdf decrypted.pdf to produce an unprotected copy. In Python, call reader.decrypt("password") on a pypdf PdfReader before accessing pages.