pdf-extractlisted
Install: claude install-skill henkisdabro/wookstar-claude-plugins
# PDF Text Extraction
Extract text from PDF files using pymupdf via `uv run --with pymupdf`.
## Prerequisites
- `uv` installed - see <https://docs.astral.sh/uv/getting-started/installation/>
- No venv or pre-installation needed - `uv run --with` handles caching automatically
## Extract text from a single PDF
```bash
uv run --with pymupdf python3 -c "
import fitz
doc = fitz.open('/path/to/file.pdf')
for page in doc:
text = page.get_text().strip()
if text:
print(text)
print()
"
```
## Extract and save to file
```bash
uv run --with pymupdf python3 -c "
import fitz
doc = fitz.open('/path/to/file.pdf')
pages = []
for page in doc:
text = page.get_text().strip()
if text:
pages.append(text)
with open('/path/to/output.txt', 'w') as f:
f.write('\n\n'.join(pages))
print(f'Extracted {len(pages)} pages')
"
```
## Extract specific pages
```bash
uv run --with pymupdf python3 -c "
import fitz
doc = fitz.open('/path/to/file.pdf')
# Pages are 0-indexed
for i in range(2, 5): # Pages 3-5
text = doc[i].get_text().strip()
if text:
print(text)
"
```
## Batch extract from multiple PDFs
```bash
uv run --with pymupdf python3 -c "
import fitz
import glob
import os
for pdf_path in glob.glob('/path/to/folder/*.pdf'):
doc = fitz.open(pdf_path)
text = '\n\n'.join(p.get_text().strip() for p in doc if p.get_text().strip())
out_path = pdf_path.rsplit('.', 1)[0] + '.txt'
with open(out_path, 'w') as f:
f.write(t