pdf-extract
Use when extracting text, images, tables, or metadata from PDF files. MUST load to choose the correct extraction library based on PDF complexity — simple text vs structured data vs complex layouts.
- License 许可
- MIT
- 最近更新
- 2026-08-20
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- pdf-extract
- tags
- [ "research", "integration" ]
- tools
- []
- version
- 1.0.0
- agent_types
- [ "planner", "worker", "reviewer" ]
- description
- Use when extracting text, images, tables, or metadata from PDF files. MUST load to choose the correct extraction library based on PDF complexity — simple text vs structured data vs complex layouts.
- dependencies
- []
03 SKILL.md 正文
PDF Extraction
Iron Laws
<EXTREMELY-IMPORTANT>
- Match the library to the PDF. Simple text →
pdf-parseorpdfjs. Structured data →pdfplumber(Python) orcamelot. Complex layouts → vision model (GPT-4V, Claude). - Test on a sample first. Don't pick a library for a 500-page contract PDF before seeing it extract right.
- Tables are not text.
pdftotextwon't give you a table. Use a table-aware tool. - Scanned PDFs need OCR first.
pytesseract,tesseract, or vision model. Don't expect text from an image. - Preserve structure when needed. A table is a 2D thing; flattening to 1D text loses it. </EXTREMELY-IMPORTANT>
When to Use
Extracting text from PDFs; tabular data; images; metadata; "convert this PDF to X"; batch processing; RAG.
When NOT to Use
Data exists in a non-PDF format (use that); copy-paste works; one-time, hand inspection.
Library Selection
| PDF type | Library |
|---|---|
| Simple text, English | pdf-parse, pdfplumber |
| Complex text, multi-column | pdfplumber (layout-aware) |
| Tables (financial, scientific) | camelot, tabula-py, pdfplumber |
| Scanned (image-based) | pytesseract (OCR), or vision model |
| Mixed (text + tables + images) | Vision model (GPT-4V, Claude) |
| Form fields | pdf-lib, pdfrw, pypdf |
When in doubt: pdfplumber for English text, vision model for weird layouts.
Workflow
- Inspect the PDF. Open it, look at the structure. Is it text or scanned? Tables? Forms? Images? Multi-column?
- Pick the library based on the structure.
- Test on a small sample. Extract 1-5 pages. Is the output what you expected?
- Scale up. Run on the full set. Watch for failures (encrypted, corrupted, etc.).
- Verify. Spot-check. Automated extraction lies silently — a missing column, a merged cell.
Common Patterns
# pdfplumber — text + tables
import pdfplumber
with pdfplumber.open("file.pdf") as pdf:
for page in pdf.pages:
text = page.extract_text()
tables = page.extract_tables()
# pytesseract — OCR
import pytesseract
from PIL import Image
text = pytesseract.image_to_string(Image.open("scan.png"))
Common Mistakes
pdftotext on a scanned PDF (no text to extract); pdf-parse on a multi-column PDF (text jumbled); flattening tables to text (loses structure); no verification (output silently wrong); choosing a library for a 500-page PDF without testing on 5 pages; OCR on text-based PDF (overkill, slower, less accurate); batch processing without error handling (one bad PDF kills the run).
Red Flags
No sample test before full run; no verification of output; pdftotext on scanned PDF; no error handling on batch; "the extraction worked on 1 page" assumption for the full 500; tables flattened to text; "I'll fix the output in post" (extraction should be correct); "the library says it supports tables" (test it on YOUR tables).
Anti-Patterns
Wrong library for the PDF (text vs scanned vs tables); no sample test; no verification; flattening tables (loses structure); OCR on text-based PDF; batch without error handling; "the library supports X" (test YOUR data); "I'll fix in post" (extraction should be right).
04 同仓库更多 Skills
writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment - applies TDD to process documentation by testing with subagents before writing, iterating until bulletproof against rationalization. Includes complete pressure testing methodology.
verification-before-completion
Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always
typescript-coding-standards
Use when writing, refactoring, or reviewing TypeScript code that needs strong domain modeling, typed errors, schema parsing, safe adapters, test seams, or maintainable module boundaries.
test-driven-development
Use when implementing a feature, bugfix, or behavior-changing refactor — require a failing behavior test before production code, then make the smallest change that passes.
source-driven-development
Use when unfamiliar libraries, dependency internals, external APIs, framework behavior, migrations, or current ecosystem guidance require official documentation, version-matched source, read the tests, and cited evidence.
security-and-hardening
Use when auditing security, implementing authentication or authorization, handling secrets, or validating data across external trust boundaries.