$npx -y skills add henkisdabro/wookstar-claude-plugins --skill pdf-extractFast, zero-AI text extraction from PDFs that have a text layer (digitally created PDFs from Word, Typst, WeasyPrint, wkhtmltopdf, LaTeX, etc). Uses pymupdf (fitz) - instant and deterministic. Use when you need to quickly pull raw text from a known text-layer PDF, e.g. "extract te
| 1 | # PDF Text Extraction |
| 2 | |
| 3 | Extract text from PDF files using pymupdf via `uv run --with pymupdf`. |
| 4 | |
| 5 | ## Prerequisites |
| 6 | |
| 7 | - `uv` installed - see <https://docs.astral.sh/uv/getting-started/installation/> |
| 8 | - No venv or pre-installation needed - `uv run --with` handles caching automatically |
| 9 | |
| 10 | ## Extract text from a single PDF |
| 11 | |
| 12 | ```bash |
| 13 | uv run --with pymupdf python3 -c " |
| 14 | import fitz |
| 15 | doc = fitz.open('/path/to/file.pdf') |
| 16 | for page in doc: |
| 17 | text = page.get_text().strip() |
| 18 | if text: |
| 19 | print(text) |
| 20 | print() |
| 21 | " |
| 22 | ``` |
| 23 | |
| 24 | ## Extract and save to file |
| 25 | |
| 26 | ```bash |
| 27 | uv run --with pymupdf python3 -c " |
| 28 | import fitz |
| 29 | |
| 30 | doc = fitz.open('/path/to/file.pdf') |
| 31 | pages = [] |
| 32 | for page in doc: |
| 33 | text = page.get_text().strip() |
| 34 | if text: |
| 35 | pages.append(text) |
| 36 | |
| 37 | with open('/path/to/output.txt', 'w') as f: |
| 38 | f.write('\n\n'.join(pages)) |
| 39 | |
| 40 | print(f'Extracted {len(pages)} pages') |
| 41 | " |
| 42 | ``` |
| 43 | |
| 44 | ## Extract specific pages |
| 45 | |
| 46 | ```bash |
| 47 | uv run --with pymupdf python3 -c " |
| 48 | import fitz |
| 49 | |
| 50 | doc = fitz.open('/path/to/file.pdf') |
| 51 | # Pages are 0-indexed |
| 52 | for i in range(2, 5): # Pages 3-5 |
| 53 | text = doc[i].get_text().strip() |
| 54 | if text: |
| 55 | print(text) |
| 56 | " |
| 57 | ``` |
| 58 | |
| 59 | ## Batch extract from multiple PDFs |
| 60 | |
| 61 | ```bash |
| 62 | uv run --with pymupdf python3 -c " |
| 63 | import fitz |
| 64 | import glob |
| 65 | import os |
| 66 | |
| 67 | for pdf_path in glob.glob('/path/to/folder/*.pdf'): |
| 68 | doc = fitz.open(pdf_path) |
| 69 | text = '\n\n'.join(p.get_text().strip() for p in doc if p.get_text().strip()) |
| 70 | out_path = pdf_path.rsplit('.', 1)[0] + '.txt' |
| 71 | with open(out_path, 'w') as f: |
| 72 | f.write(text) |
| 73 | print(f'{os.path.basename(pdf_path)}: {len(doc)} pages extracted') |
| 74 | " |
| 75 | ``` |
| 76 | |
| 77 | ## Get PDF metadata |
| 78 | |
| 79 | ```bash |
| 80 | uv run --with pymupdf python3 -c " |
| 81 | import fitz |
| 82 | doc = fitz.open('/path/to/file.pdf') |
| 83 | meta = doc.metadata |
| 84 | print(f'Title: {meta.get(\"title\", \"N/A\")}') |
| 85 | print(f'Author: {meta.get(\"author\", \"N/A\")}') |
| 86 | print(f'Pages: {len(doc)}') |
| 87 | print(f'Creator: {meta.get(\"creator\", \"N/A\")}') |
| 88 | " |
| 89 | ``` |
| 90 | |
| 91 | ## Key notes |
| 92 | |
| 93 | - pymupdf is imported as `fitz` (legacy naming from the MuPDF library) |
| 94 | - Pages are 0-indexed: `doc[0]` is the first page |
| 95 | - `get_text()` returns plain text; use `get_text("blocks")` for positioned blocks |
| 96 | - `get_text("html")` returns HTML with formatting preserved |
| 97 | - The package caches after the first `uv run --with pymupdf` invocation - subsequent runs are instant |
| 98 | |
| 99 | ## When to use this vs pdf-processing-pro |
| 100 | |
| 101 | | Use pdf-extract | Use pdf-processing-pro | |
| 102 | |---|---| |
| 103 | | PDF created digitally (Word, Typst, LaTeX, wkhtmltopdf, WeasyPrint) | Scanned or image-based PDF (photo, fax, scan) | |
| 104 | | Need raw text quickly - less than a second | Need structured output: tables, headings, forms | |
| 105 | | Bulk/batch extraction without AI cost | OCR required (scanned documents) | |
| 106 | | Offline, no API key, no extra dependencies | Form filling, validation, batch workflows | |
| 107 | | Simple text content, no tables needed | Tables or structured layout are important | |