PDF Field Extractor: Using an Agent to Extract Key PDF Fields into Excel or JSON

Preface

PDFs sent by colleagues in finance, legal, and operations often need to be manually transcribed into spreadsheets or systems: invoice numbers, amounts, contract parties, reconciliation details row by row - slow and error-prone. Common approaches are local scripts that only do text-layer extraction, or throwing the entire PDF to general conversational models, resulting in unstable field formats and batch results.

Below we introduce the SkillHub community Skill Pdf Field Extractor (coordinate @user_26bdbd50/pdf-field-extractor, current version 1.0.2). It chains “read PDF → determine document type → use LLM to extract fields → export structured files” into a reusable workflow, suitable for attaching to Agents that support Skills like Cursor, where the model calls the bundled Python scripts according to SKILL.md.

What Is This

Pdf Field Extractor is an office efficiency Skill maintained by community publisher user_26bdbd50 (SkillHub category office-efficiency, source community). Its positioning is: AI-driven PDF structured extraction, organizing key fields from documents like invoices, contracts, receipts, etc. into Excel (.xlsx) or JSON.

The SkillHub page marks requires_api_key=true: the field extraction stage requires users to provide their own OpenAI-compatible LLM API Key, and the Skill does not manage keys on the user’s behalf. Page statistics (as shown on SkillHub): rating 100000, downloads 1218, installs 25.

Official access:

  • API page: https://api.skillhub.cn/user_26bdbd50/pdf-field-extractor
  • Display page: https://www.skillhub.cn/skills/user_26bdbd50/pdf-field-extractor

Core Features

The following capabilities are all derived from the SKILL.md / SKILLHUB.md and scripts/ implementations within the Skill package, and the entire pipeline can be understood by module.

End-to-End Pipeline

  1. User provides PDF (or batch files).
  2. Document type identification (scripts/doc_type_identifier.py): invoices, contracts, receipts, bank statements, business licenses, ID cards, express waybills, general documents, etc.
  3. PDF text and tables (scripts/pdf_extractor.py): PyMuPDF extracts text, pdfplumber preserves table structure; when there is no text layer, it is marked as a scanned document.
  4. OCR (scripts/ocr_processor.py): scanned documents go through pytesseract, supporting Chinese, English, Japanese, Korean and other languages along with basic image preprocessing.
  5. AI field extraction (scripts/field_extractor.py): based on document type or user-defined field list, calls OpenAI-compatible interfaces (such as GPT-4o, MiniMax, DeepSeek, Doubao, etc., subject to user configuration).
  6. Output (scripts/output_generator.py): generates Excel / JSON; the documentation also mentions the ability to assemble Feishu message summaries.
  7. Batch (scripts/batch_processor.py): parallel processing of multiple files (max_workers configurable).

Plans and Usage (Built into Skill)

SKILL.md and scripts/tier_config.py define tiers distinguished by token prefixes (such as PDF-FREE, PDF-BSC, etc.), including monthly page limits, number of document types, output format restrictions, etc. If you enable paid tiers, you must use them under the plan rules described in the Skill; the free tier example is approximately 10 pages per month, focused on invoice types and text output. The specific pricing table is subject to the Skill documentation.

Installation and Activation

Method 1: Let the Agent install according to SkillHub guidance

The installation prompt given by the SkillHub display page is: read https://skillhub.cn/install/skillhub.md, and install @user_26bdbd50/pdf-field-extractor.

Method 2: SkillHub CLI

First confirm that skillhub is installed on your machine (see the above skillhub.md for installation instructions). During installation, you must use --dir to point to the current Agent’s skills directory, otherwise the default ./skills/ location may not be recognized.

skillhub install pdf-field-extractor --namespace user_26bdbd50 --dir ~/.cursor/skills/

Common Skills directories (excerpted from the SkillHub installation documentation, choose according to your actual client):

  • Cursor: ~/.cursor/skills/
  • Claude Code: ~/.claude/skills/
  • Codex: ~/.codex/skills/ or .agents/skills/ under the project

After installation is complete, restart or refresh the Agent so the new Skill is loaded.

Runtime Dependencies

SKILLHUB.md requires Python 3.8+. Processing scanned documents requires Tesseract OCR to be installed on the system, Ubuntu/Debian example:

sudo apt install tesseract-ocr tesseract-ocr-chi-sim tesseract-ocr-jpn tesseract-ocr-kor

Python dependencies (versions subject to the Skill documentation):

pymupdf>=1.23.0
pdfplumber>=0.10.0
pytesseract>=0.3.10
pandas>=2.0.0
openpyxl>=3.0.0
Pillow>=10.0.0
requests>=2.28.0

After installing the above packages within the Skill’s extracted directory, the Agent or local scripts can call from scripts....

API Key

Field extraction requires passing the user’s own api_key, and api_base, model can be configured. Do not commit real keys in repositories or conversations; manage them in the Agent’s environment variables or secure configuration instead.

Typical Usage

The Skill’s description lists trigger intents, such as: PDF extraction, PDF field extraction, PDF to Excel, invoice extraction, contract extraction, batch PDF, etc. Users just need to upload a PDF and specify which fields to extract, for example:

帮我提取这张发票的关键信息
[上传 invoice.pdf]

The Agent should follow the Skill workflow to identify the document type, extract invoice number, date, amount, buyer and seller, etc., and output Excel or JSON.

Batch scenario example:

批量处理这 10 份 PDF,结果合并到一个 Excel

Using Python within the Skill Directory (Consistent with Documentation)

The following code is excerpted from SKILL.md, showing a three-step invocation; paths are relative to the Skill root directory:

from scripts.pdf_extractor import extract_pdf_text
from scripts.field_extractor import extract_fields
from scripts.output_generator import generate_excel, generate_json

text, tables, is_scanned = extract_pdf_text("invoice.pdf")

fields = extract_fields(
    text=text,
    doc_type="invoice",
    api_key="sk-xxx",
    api_base="https://api.openai.com/v1",
    model="gpt-4o",
)

generate_excel(fields, "output.xlsx")
generate_json(fields, "output.json")

For general documents, custom_fields can be specified; for scanned documents when is_scanned is true, the workflow should combine scripts/ocr_processor.py to complete the text first before extraction. For batch processing, call process_batch and then uniformly call generate_excel.

For more detailed document type rules and Prompt templates, see references/doc_types.md and references/prompts.md within the Skill.

Use Cases and Notes

Who It’s For

  • Teams that need to batch-enter PDFs like invoices, contracts, receipts, statements into spreadsheets or downstream systems.
  • Developers or implementation personnel who are already using Skills in environments like Cursor / Claude Code / Codex and want to use unified scripts instead of hand-writing extraction logic each time.

Limitations and Notes

  • Must provide your own LLM API: without a Key, AI field extraction cannot be completed; call costs and compliance are borne by the user.
  • Scanned document quality: the documentation suggests approximately 300dpi clarity; OCR depends on Tesseract, and complex layouts still require manual spot checks.
  • Plans and page counts: tier_config will validate page count, document types, and output formats; exceeding tiers will cause errors, so check scripts/tier_config.py before deployment.
  • Sensitive data: PDF content will be parsed locally and may be sent to the model API you configure; for confidential materials, please pass security review first.
  • The Skill documentation mentions support for OFD, XML electronic invoices and other formats; actual capabilities depend on the scripts in the current package; for new formats, it is recommended to validate with a single sample first.

Conclusion

Pdf Field Extractor consolidates PDF parsing, type identification, OCR, LLM field extraction, and Excel/JSON export into a single Skill, reducing reinvention of the wheel. If your daily workflow already has an Agent resident, install it into the corresponding skills directory, and then describe fields in natural language to run the complete pipeline.

For details and installation instructions, see SkillHub: https://www.skillhub.cn/skills/user_26bdbd50/pdf-field-extractor

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye