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.
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.
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.
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).
This guide covers essential PDF processing operations using Python libraries and command-line tools.
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.
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.
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.
**Always validate bounding boxes before filling:**
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.
The fill script auto-detects the coordinate system and handles conversion:
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.
Requires: pip install pytesseract pdf2image
2Core Capabilities
3External Dependencies
| Kind | Dependency / Endpoint |
|---|---|
| package | pypdf(读写/合并/旋转/加密/字段) |
| package | pdfplumber(文本/表格坐标级抽取) |
| package | reportlab(创建 PDF) |
| cli | pdftotext(poppler-utils) |
| cli | qpdf(合并/拆分/旋转/修复/加密) |
| cli | pdftk(若可用)与 pdfimages(poppler,抽图) |
| package | pytesseract + pdf2image(OCR,按需安装) |
| package | pypdfium2 / pdf-lib(JS) / pdfjs-dist(JS)(高级参考章节) |
4Recommended Governance & Evidence
- 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)
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
8a9ce019ed1b048d…