📄 SKILL.md
When to Use
Agent needs to get text content from PDFs. Works with text-based documents, scanned pages, forms, and complex layouts. Perfect for document analysis, invoice processing, or feeding content to LLMs.
Quick Reference
| Topic | File |
|-------|------|
| CLI commands | cli.md |
| Python API | api.md |
| Output formats | formats.md |
| OCR setup | ocr.md |
| Problems & fixes | troubleshooting.md |
Core Rules
1. Pick the Right Method
| PDF Type | What to Do |
|----------|------------|
| Normal (text-based) | Direct extraction — fast |
| Scanned image | OCR with --ocr — slower |
| Mixed pages | Auto-detect with --auto (default) |
2. Choose Output Format
| Format | Best For |
|--------|----------|
| text | LLM input, search indexing |
| json | Metadata + stats + structure |
| markdown | Preserve headings, lists |
3. Handle Large Files
`bash
Limit pages to avoid memory issues
extract-pdf-text large.pdf --pages 1-20
Batch multiple files
extract-pdf-text *.pdf --batch --outdir ./results/
`
4. Check Confidence on OCR
OCR returns a confidence score (0-1). Below 0.8 = review recommended.
`python
result = extract("scanned.pdf", ocr=True)
if result.confidence < 0.8:
print("⚠️ Low confidence — verify output")
`
5. Preserve Structure When Needed
Tables and headings get lost by default. Keep them:
`bash
extract-pdf-text report.pdf --preserve-structure -f markdown
`
Extraction Traps
| Trap | What Happens | Fix |
|------|--------------|-----|
| OCR on text PDF | Slow + worse results | Let auto-detect work |
| No language hint | Garbage OCR output | Use --lang spa (or your language) |
| Giant PDF, no limit | Memory crash | Add --pages 1-50 |
| Trust low-confidence OCR | Bad data in your system | Check confidence > 0.8 |
Scope
This skill ONLY:
This skill NEVER:
Security & Privacy
Everything stays local:Usage
Quick Start
`bash
Basic — prints to stdout
extract-pdf-text document.pdf
Save to file
extract-pdf-text document.pdf -o output.txt
Scanned document with OCR
extract-pdf-text scan.pdf --ocr --lang eng -o output.txt
Batch process folder
extract-pdf-text *.pdf --batch --outdir ./extracted/
`
Python
`python
from extract_pdf_text import extract
result = extract("document.pdf")
print(result.text)
print(f"{result.pages} pages, {result.word_count} words")
With OCR
result = extract("scan.pdf", ocr=True, lang="eng")
print(f"Confidence: {result.confidence}")
`
What You Get
`json
{
"text": "Extracted content...",
"pages": 10,
"word_count": 5432,
"method": "text",
"confidence": 1.0,
"metadata": {
"title": "Document Title",
"author": "Author Name",
"created": "2026-01-15"
}
}
`
Feedback
clawhub star extract-pdf-textclawhub sync