Process PDFs by identifying the operation, selecting the right tool, implementing, and verifying output.
When NOT to use
- The task is pure image processing (no PDF involved) — use image-specific tools instead.
- The PDF is a scanned image where no text extraction is needed — the skill handles OCR internally, but if you only need image manipulation of extracted pages, route differently.
1. Identify the operation
Determine what the user wants to do:
- Read/extract: text, tables, metadata, images
- Transform: merge, split, rotate, watermark, encrypt/decrypt
- Create: new PDFs from scratch or from other formats
- OCR: scanned PDFs that need text recognition
2. Select library or tool
Choose based on the operation:
| Operation |
Primary tool |
Alternative |
| Read/extract text |
pdfplumber |
pypdf |
| Extract tables |
pdfplumber + pandas |
— |
| Merge/split/rotate |
pypdf |
qpdf (CLI) |
| Create PDFs |
reportlab |
— |
| OCR |
pytesseract + pdf2image |
— |
| Forms |
pypdf |
pdf-lib (JS) |
| Encrypt/decrypt |
pypdf |
qpdf (CLI) |
Check that the library is installed; install if missing. For the forms workflow (detect fillable fields, extract field info, fill, annotate), use pypdf field APIs directly (AcroForm / update_page_form_field_values). If a bundled forms.md reference is added to this skill in the future, load it for scripts/ helpers. Advanced / second-tier libraries (pypdfium2, etc.) are documented in references/ when present.
Common code snippet (use directly for routine work)
Read text with pdfplumber:
import pdfplumber
with pdfplumber.open("input.pdf") as pdf:
for page in pdf.pages:
print(page.extract_text())
All other snippets (merge, split, rotate, watermark, encrypt, create, OCR, CLI tools) live in references/code-snippets.md.
3. Implement the operation
Write a script that:
- Reads input PDF(s) with the selected library
- Performs the operation
- Writes output to the specified location
- Handles errors (missing files, corrupt PDFs, permission issues)
4. Verify output
- Confirm the output file exists and is non-empty
- Spot-check content (e.g., page count, extracted text sample, table row count)
- Report results to the user
Completion criteria
Related skills
xlsx — sibling file-doc skill (share zero-error bar).
data-access — read .pdf table via DuckDB fallback when needed.
1---2name: pdf3description: Use when the user needs to read, extract, merge, split, rotate, create, watermark, encrypt, or OCR a PDF file.4---56Process PDFs by identifying the operation, selecting the right tool, implementing, and verifying output.78## When NOT to use910- The task is pure image processing (no PDF involved) — use image-specific tools instead.11- The PDF is a scanned image where no text extraction is needed — the skill handles OCR internally, but if you only need image manipulation of extracted pages, route differently.1213## 1. Identify the operation1415Determine what the user wants to do:16- **Read/extract:** text, tables, metadata, images17- **Transform:** merge, split, rotate, watermark, encrypt/decrypt18- **Create:** new PDFs from scratch or from other formats19- **OCR:** scanned PDFs that need text recognition2021## 2. Select library or tool2223Choose based on the operation:2425| Operation | Primary tool | Alternative |26|-----------|-------------|-------------|27| Read/extract text | pdfplumber | pypdf |28| Extract tables | pdfplumber + pandas | — |29| Merge/split/rotate | pypdf | qpdf (CLI) |30| Create PDFs | reportlab | — |31| OCR | pytesseract + pdf2image | — |32| Forms | pypdf | pdf-lib (JS) |33| Encrypt/decrypt | pypdf | qpdf (CLI) |3435Check that the library is installed; install if missing. For the **forms** workflow (detect fillable fields, extract field info, fill, annotate), use `pypdf` field APIs directly (`AcroForm` / `update_page_form_field_values`). If a bundled `forms.md` reference is added to this skill in the future, load it for `scripts/` helpers. Advanced / second-tier libraries (`pypdfium2`, etc.) are documented in `references/` when present.3637### Common code snippet (use directly for routine work)3839**Read text with pdfplumber:**40```python41import pdfplumber42with pdfplumber.open("input.pdf") as pdf:43 for page in pdf.pages:44 print(page.extract_text())45```4647All other snippets (merge, split, rotate, watermark, encrypt, create, OCR, CLI tools) live in [`references/code-snippets.md`](references/code-snippets.md).4849## 3. Implement the operation5051Write a script that:52- Reads input PDF(s) with the selected library53- Performs the operation54- Writes output to the specified location55- Handles errors (missing files, corrupt PDFs, permission issues)5657## 4. Verify output5859- Confirm the output file exists and is non-empty60- Spot-check content (e.g., page count, extracted text sample, table row count)61- Report results to the user6263## Completion criteria6465- [ ] Operation type and input/output files identified66- [ ] Tool selected and available in the environment67- [ ] Script runs without errors68- [ ] Output file exists and is non-empty69- [ ] Content spot-checked (page count, text sample, table row count)70- [ ] User informed of results7172## Related skills7374- `xlsx` — sibling file-doc skill (share zero-error bar).75- `data-access` — read `.pdf` table via DuckDB fallback when needed.