首页 / Skills / 办公与文档 / PDF 工具箱 PDF Toolkit
办公与文档

PDF 工具箱 PDF Toolkit

AIBarsMITSkill 语言: 英文
协议已核对不含脚本中风险
演示真实运行记录 · claude-sonnet-5-5 · 2026年10月
I need three things done in this folder, all with made-up sample content: 1. Create a one-page PDF called invoice.pdf for a fictional company "Northwind Sample Co" with a small table of 3 line items and a total (mark everything as sample). 2. Create a second one-page PDF called terms.pdf with a short heading and three bullet-point terms (sample text). 3. Merge them into combined.pdf (invoice first), then extract the text and the table from combined.pdf and tell me what you found. Verify the result before you answer.
Skill: pdf-toolkit

I created all three PDFs and checked them. The one oddity is that the bullet characters in terms.pdf come out as (cid:127) when extracted.

Files (in the working folder, built by scripts/make.py, checked by scripts/check.py):

  • invoice.pdf is 1 page. It has a title for "Northwind Sample Co" and three line items, and everything is marked as sample.
  • terms.pdf is 1 page. It has the heading "Sample Terms" and three bullet terms.
  • combined.pdf is 2 pages, with the invoice first and the terms second. That matches 1 + 1 pages.

Text extracted from combined.pdf

  • Page 1 has the invoice title, the "fictional / made-up sample data" note, the table rows, and the "SAMPLE - not a real invoice." footer.
  • Page 2 has "Sample Terms" and the three terms: payment due in 30 days, 1% monthly late fee, and goods remaining sample property until paid. Each one is marked "(sample term)".

Table extracted from page 1 (one table found):

Item Qty Unit Price Amount
Sample Widget 10 $5.00 $50.00
Sample Gadget 2 $25.00 $50.00
Sample Service Hour 4 $30.00 $120.00
Total $220.00

Verification: The line items add up: 50 + 50 + 120 = 220, which matches the stated total. The extracted table has the same 5 rows and 4 columns I built, with no merged or missing cells.

Problem: pdfplumber reads the bullet glyph as (cid:127) instead of "•". That is how the built-in Helvetica font encodes the bullet, so it is probably an extraction quirk and the bullets should display normally. I haven't rendered the pages, so I can't confirm how they look. If clean extracted text matters to you, I can switch to a plain "-" marker.

Test run: two sample one-page PDFs built with reportlab, merged with pypdf, then read back with pdfplumber, in a temporary folder. The run was allowed to write files and run python3 only. I re-opened the files myself: 1 + 1 pages merged into 2, and the table text matched. The model flagged that the bullet glyph extracts as (cid:127). Pages were not rendered, so appearance was not checked. All content is sample.

它做什么

使用三个常见的库:pypdf 处理结构(合并、拆分、调整顺序、旋转、表单、元数据),pdfplumber 提取文字和表格,reportlab 生成新的 PDF。它先检查每个输入文件(页数、尺寸、是否加密、表单字段,以及每页能提取多少文字,借此尽早发现扫描页),再执行任务,并重新打开每个输出,核对页数、文字样本、表单值和文件大小。它会报告没有可提取文字的页面,说明需要 OCR,并在提取出的表格可能不可靠时给出提醒。它只在你提供密码、且你有权使用该文件时打开受保护的 PDF,不会尝试破解保护。

输出

新的 PDF 文件和生成它们的脚本、改动了什么、核对结果,以及发现的问题,比如扫描页或缺少字体。

适合什么场景

合并和拆分文档,从报告里提取表格,加水印和页码,填写表单,生成简单的发票或报告。

说明与风险

中风险:纯指令文件,自身没有脚本,但它会编写并运行 Python,在你的工作目录里创建文件,也可能建议在虚拟环境里安装 pypdf、pdfplumber 和 reportlab。它不会覆盖你的原文件,也不会破解密码保护。已在临时目录用示例 PDF 试用一次:生成了两份 PDF、合并并正确提取了表格;项目符号在提取时变成了 (cid:127),并且没有渲染页面,所以外观没有检查。AIBars 原创(MIT)。

SKILL.md 原文包内共 2 个文件