pdf-toolkit
它能做什么
这项技能完成结构化的 PDF 任务,例如从报告中提取表格或合并文件。它适合处理 PDF、并希望结果精确且可重复的人。
适用场景
- ✓当你需要从 PDF 报告中提取文本或表格时。
- ✓当你希望把多个 PDF 合并成一个,或按页码范围拆分 PDF 的时候。
- ✓当你需要填写 PDF 表单字段,或根据数据制作新 PDF 的时候。
技能链接
https://github.com/TokenRhythm/opensquilla/blob/main/src/opensquilla/skills/bundled/pdf-toolkit/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我把这三份 PDF 报告合并成一个文件,并从第二份中提取表格。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会为任务选择合适的脚本,例如提取、合并、拆分或填写表单,并对工作区中的文件运行。它会返回结果和完成的 PDF。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
pdf-toolkit
Deterministic, structural PDF operations. Use this skill for programmatic work where you know exactly what you want done. For a natural-language rewrite, first draft the replacement content with ordinary reasoning, then use the explicit extract/generate/merge operations here to create the final PDF.
Use the inline Python examples with execute_code in a restricted channel.
Keep files in the active workspace and call publish_artifact with the
finished PDF. Shell commands below require an available exec_command;
they are optional shortcuts, not a reason to request host execution. If the
sandbox or a required library is unavailable, report the limitation rather
than retrying outside the sandbox.
Decide the operation
| Goal | Script |
|---|---|
| Get text or tables out of a PDF | extract.py |
| Combine pages from multiple PDFs | merge.py |
| Split a PDF by page ranges | split.py |
Fill /Tx form fields in a PDF |
form_fill.py |
| Build a new PDF from data | inline reportlab snippet, see Path C below |
Path A: Extract
python {baseDir}/scripts/extract.py /path/to/doc.pdf --json
Output:
{
"pages": 12,
"metadata": {"title": "...", "author": "..."},
"text": [
{"page": 1, "content": "..."},
{"page": 2, "content": "..."}
],
"tables": [
{"page": 3, "rows": [["..."], ["..."]]}
]
}
Text uses pdfplumber (already in default dependencies) which preserves
column layout better than naive PDF text extraction. Tables use
pdfplumber.extract_tables() with default settings; for tricky layouts
pass --tables-strategy lines|text|explicit to switch detection mode.
For OCR (scanned PDFs), this skill does not include Tesseract — use the sibling skill that wraps an OCR engine (out of scope here).
Path B: Merge / Split
Merge full files:
python {baseDir}/scripts/merge.py a.pdf b.pdf c.pdf --out combined.pdf
Or merge specific page ranges with the manifest form:
python {baseDir}/scripts/merge.py manifest.json --out combined.pdf
manifest.json:
[
{"file": "a.pdf", "pages": "1-3"},
{"file": "b.pdf", "pages": "5,7,9-11"},
{"file": "c.pdf"}
]
Page ranges are 1-based, comma-separated, hyphen for ranges. Omit pages to
include the whole file. Splits use the same syntax in reverse:
python {baseDir}/scripts/split.py input.pdf --pages "1-3,7,10-12" --out output_dir/
Each range writes one output file: output_dir/input_001.pdf,
output_dir/input_002.pdf, …
Path C: Form fill
python {baseDir}/scripts/form_fill.py form.pdf data.json --out filled.pdf
data.json maps field name → string value:
{
"applicant_name": "Wei E.",
"submission_date": "2026-05-06",
"agreed": "Yes"
}
The script discovers fields via pypdf.PdfReader.get_fields() and updates
them with update_page_form_field_values(). Fields not present in the JSON
are left untouched. Run with --list-fields to enumerate the form's fields
without filling.
Caveats:
/Btncheckbox fields take the export value (oftenYes,On, or1) rather thantrue— inspect with--list-fieldsto discover.- AcroForm fills only. XFA forms (used by some legal templates) require Adobe-specific tooling and are out of scope.
- Some signed PDFs invalidate the signature when fields change. Strip
signatures explicitly with
--clear-signaturesif that is intended.
Path D: Generate from scratch
Use reportlab directly when you need a new PDF:
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import LETTER
from pathlib import Path
c = canvas.Canvas(str(Path("out.pdf")), pagesize=LETTER)
c.setFont("Helvetica-Bold", 18)
c.drawString(72, 720, "Q3 Review")
c.setFont("Helvetica", 11)
c.drawString(72, 696, "Revenue grew 18% year over year.")
c.showPage()
c.save()
For Chinese text, register a CJK font instead of Helvetica. ReportLab's CID font works without downloading fonts or reading a user font directory:
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.cidfonts import UnicodeCIDFont
from reportlab.pdfgen import canvas
pdfmetrics.registerFont(UnicodeCIDFont("STSong-Light"))
c = canvas.Canvas("report.pdf")
c.setFont("STSong-Light", 14)
c.drawString(72, 760, "季度报告:收入增长")
c.save()
CID fonts rely on PDF reader CJK support. When an embedded font is required, use a licensed font already available inside the workspace or permitted
常见问题
它会改写 PDF 的内容吗?
不会直接改写。如需改写,智能体会先起草新内容,再用这些工具生成最终的 PDF。
文件保存在哪里?
文件保存在当前工作区中,完成的 PDF 也从那里发布。
如果所需的库不可用怎么办?
该技能会说明这一限制,而不会在沙盒之外重试。
详情
作者的原始描述
Structured `.pdf` operations: extract text/tables, merge pages from multiple PDFs, split a PDF by page ranges, fill PDF form fields, and generate fresh PDFs from JSON. Trigger when the user wants deterministic programmatic PDF work — examples: pull tables from a report, combine three PDFs, extract pages 5-12, fill a tax form, or build a new PDF from data. This is the single public PDF entry and uses pypdf, pdfplumber, and reportlab.
repo: TokenRhythm/opensquilla
热度
- GitHub 星标
- 7.1k
- 排名
- #13590
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
browser-use
7.1k让你的智能体在 OpenSquilla Desktop 侧边栏浏览器中打开、阅读和操作网页,包括填写表单和进行视觉检查。
deep-research
7.1k教你的智能体进行多轮研究,使用已保存的计划、已追踪的来源,并生成带引用的长篇报告。
docx
7.1k帮你的智能体阅读、编辑或创建 Word .docx 文件,同时保持格式、修订记录和结构完整。
html-coder
7.1k帮你的智能体编写结构清晰的 HTML 页面,包含无障碍表单、媒体和 HTML5 功能,并可作为网页预览打开。