Home / All Skills / Workflow & Core Tools / pdf
Workflow & Core Tools · anthropics/skills

pdf

Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.

L4 High-Privilege · Graded auth & full auditV1 Commit-PinnedExecute CommandWrite FileDual-pass Audit
Author anthropicsGitHub anthropics/skills ↗Stars 175386License Proprietary(skill 自带 LICENSE.txt:© 2025 Anthropic, PBC. All rights reserved. 按 Anthropic Consumer/Commercial Terms of Service 授权并附 ADDITIONAL RESTRICTIONS;非开源许可)Commit 41bbe19d1a
Control levels describe skill capabilities and suggested control measures; they do not represent quality or safety certifications, nor do they dictate usability. Usage decisions rest entirely with users and administrators. Different agent hosts apply varying constraints; do not assume hosts provide automatic protection. Third-party skill copyrights belong to their original authors. Use at your own risk.

1How It Works & Mechanism

Hierarchical document routing: SKILL.md contains only common recipes and "Next Step" pointers, REFERENCE.md covers advanced libraries/JS usage, and FORMS.md provides the complete end-to-end workflow for form filling—dividing responsibilities across three documents based on the task.

skills/pdf/SKILL.md
For advanced features, JavaScript libraries, and detailed examples, see REFERENCE.md. If you need to fill out a PDF form, read FORMS.md and follow its instructions.
SKILL.md is organized with a 'Quick Reference' table + recipe code blocks (pypdf for merging/splitting/rotating/watermarking/encrypting, pdfplumber for extraction, reportlab for generation, and poppler/qpdf CLI); FORMS.md serves as the full workflow for complex tasks like form filling.

Routine PDF operations follow a dual-track approach (Python libraries + CLI), both executed locally: pypdf (structural operations), pdfplumber (text/tables), reportlab (creation), and pdftotext/qpdf/pdftk/pdfimages (CLI shortcuts).

skills/pdf/SKILL.md
This guide covers essential PDF processing operations using Python libraries and command-line tools.
Recipes include pitfall workarounds: 'Never use Unicode subscript/superscript characters (₀₁₂₃₄₅₆₇₈₉…) in ReportLab PDFs'—embedded fonts lacking these glyphs will render as black boxes; use <sub>/<super> tags instead.

Form filling is a primary focus and distinguishes two formats: fillable forms (directly populating fields) and non-fillable forms (no interactive fields → overlaying FreeText annotations), with the latter prioritizing structural coordinate extraction before falling back to visual estimation.

skills/pdf/forms.md
If the PDF doesn't have fillable form fields, you'll add text annotations. First try to extract coordinates from the PDF structure (more accurate), then fall back to visual estimation if needed.
Structural approach = extract_form_structure.py (pdfplumber extracts text coordinates, horizontal lines, and small checkbox rectangles, outputting labels/lines/checkboxes/row_boundaries JSON); visual approach = image conversion followed by manual/visual positioning and scaled fine-tuning.

Strict quality gates prior to filling: check_bounding_boxes.py validates overlapping bounding boxes and undersized input boxes; mandatory post-fill visual inspection via image conversion ensures coordinate transformation errors are caught before delivery.

skills/pdf/forms.md
**Always validate bounding boxes before filling:**
Original validation criteria: 'Intersecting bounding boxes (which would cause overlapping text)' + 'Entry boxes that are too small for the specified font size'; Step 4 uses convert_pdf_to_images.py to output images for manual verification.

Consistent coordinate system conversion: forms.md defines PDF coordinates (y=0 at page top, increasing downward), fields.json includes pdf_width/pdf_height or image dimensions, and filling scripts automatically detect the coordinate system and perform transformations.

skills/pdf/forms.md
The fill script auto-detects the coordinate system and handles conversion:
fill_pdf_form_with_annotations.py source code includes the transform_from_image_coords(bounding box…) coordinate transformation function, overlaying text with pypdf FreeText annotations; fill_fillable_fields.py handles field writing via pypdf.

Scanned document OCR and "searchability" only cover text extraction: the sample extracts per-page OCR text via pdf2image → pytesseract, without providing direct scripts to generate a PDF with an embedded searchable text layer.

skills/pdf/SKILL.md
Requires: pip install pytesseract pdf2image
There is a slight phrasing discrepancy with the description 'OCR on scanned PDFs to make them searchable': the main text demonstrates extracting and printing text; creating a searchable PDF (embedding a text layer/index) requires the host environment to integrate external tools—see this discrepancy in verification.

2Core Capabilities

01Merge, split, rotate, watermark/page-number, and encrypt/decrypt PDFs (pypdf recipes)
02Extract text and tables (pdfplumber, including layout preservation and multi-page table concatenation)
03Generate PDFs from scratch (reportlab Canvas/Platypus, including sub/sup glyph workarounds)
04CLI batch operations: pdftotext -layout, qpdf merge/split, pdftk, and pdfimages image extraction
05End-to-end form-filling workflow: structural extraction → fields.json → bounding box validation → fill (field/annotation methods) → visual inspection via image conversion
06Scanned document OCR text extraction (pdf2image + pytesseract)
07Advanced reference: pypdfium2 rendering, pdf-lib (JS) complex generation, and pdfjs-dist coordinate/annotation extraction

3External Dependencies

KindDependency / Endpoint
packagepypdf(读写/合并/旋转/加密/字段)
packagepdfplumber(文本/表格坐标级抽取)
packagereportlab(创建 PDF)
clipdftotext(poppler-utils)
cliqpdf(合并/拆分/旋转/修复/加密)
clipdftk(若可用)与 pdfimages(poppler,抽图)
packagepytesseract + pdf2image(OCR,按需安装)
packagepypdfium2 / pdf-lib(JS) / pdfjs-dist(JS)(高级参考章节)

4Recommended Governance & Evidence

Suggested Controls for Safe Operation
For Agent Runtime
Graded/per-use authorization, sandbox recommended
For Administrators
Approval workflow, rollback support, full audit
Evidence & Triggers (File Paths & Excerpts)
  • scripts/: Executes local scripts or commands: 8 bundled Python scripts (pypdf/pdfplumber/PIL/pdf2image)
  • 本地工作目录: File I/O and artifact generation: outputs PDF, fields.json, form_structure.json, and images (local workspace)
Audit Notes: Fully local execution: uses bundled Python scripts + poppler/qpdf local CLIs to read and write local PDFs without outbound network requests or credential access. Considerations: (1) The attack surface for parsing untrusted PDFs resides at the pypdf/pdfplumber parser layer (host must evaluate version security); (2) While the description claims 'OCR … make them searchable', the implementation only covers text extraction, requiring host-provided tools to generate searchable PDFs; (3) OCR libraries are installed on demand via pip (official PyPI, triggered conditionally). Overall, this is a local document processing skill with no external communication risks.

5Second-Pass Verification

  • [ok] 填表工作流引用脚本全部存在 — forms.md 各步骤命令行(extract_form_structure/check_bounding_boxes/fill_pdf_form_with_annotations/convert_pdf_to_images/check_fillable_fields)与 scripts/ 文件一一对应。
  • [discrepancy] OCR『make them searchable』宣称 vs 实现 — description 声称 OCR 使扫描件可搜索,但 SKILL.md 'Extract Text from Scanned PDFs' 示例只把 pytesseract 文本拼进字符串打印/汇总;生成带文本层的可搜索 PDF 没有脚本或配方,需宿主自行组合。属轻微措辞超前(抽取是搜索化的前置),已在 risks 标注。
  • [ok] 库依赖与 import 一致 — 脚本实际 import pypdf/pdfplumber/PIL/pdf2image,与依赖清单一致;无隐藏第三方。
  • [ok] 网络/凭证零命中 — token 扫描(url/requests/urllib/env/token/secret/key)零命中;无配置文件读取。
  • [ok] 坐标转换逻辑存在 — fill_pdf_form_with_annotations.py 有 transform_from_image_coords 函数,forms.md 双坐标系说明与之配套。
  • [ok] 元数据与资产核对 — 本地 HEAD==pin;LICENSE.txt 专有条款与 frontmatter 'Proprietary' 一致;REFERENCE.md/forms.md 行数与结构如述。

6Verdict & Scenarios

  • Comprehensive task coverage: actionable execution paths for structural operations, extraction, generation, CLI batch processing, form filling, and OCR, supported by a Quick Reference lookup table.
  • Form filling is engineered as a true coordinate-driven closed loop (structural extraction → validation → filling → visual inspection) rather than naive text overlay.
  • Runs fully locally and offline: pure Python + poppler CLI with zero network dependencies, ideal for sensitive document environments.
  • Three-tier modular documentation (SKILL/REFERENCE/FORMS) avoids main document bloat while providing dedicated deep-dive manuals.
  • Built-in renderer pitfall knowledge (Unicode subscript black boxes, coordinate orientations) minimizes rework.
  • Best for: Ideal for automation environments requiring batch or programmatic PDF processing: merging/splitting contracts and reports, extracting tables, OCR on scanned files, and the challenging task of precisely filling non-interactive PDF forms (with an end-to-end workflow); the three-tier documentation structure also supports progressive usage from quick tasks to deep customizations.
    Not for: Not suitable for design-heavy PDF work requiring high-precision visual layout that demands a WYSIWYG editor; not suitable when directly generating searchable PDFs via OCR is expected without host-provided supplementary tooling; not suitable for restricted environments where poppler or qpdf cannot be installed; not suitable for organizations unable to accept proprietary licensing terms.
    Install Agent-Ready
    ① Verified Mirror 2026-09-09
    Option A · Direct DownloadDownload pdf.tar.gz
    sha256: 8a9ce019ed1b048d…
    Option B · Copy Guide for Agent
    install.json
    Agents automatically download and verify mirrors from this JSON guide.
    ② Upstream GitHub
    GitHub Repo ↗
    Pinned to commit 41bbe19d1a.