首頁 / 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 個檔案