--- name: document-tools description: "Document processing: PDF editing (nano-pdf) and text extraction from PDFs/scans (pymupdf, marker-pdf)." version: 1.0.0 author: Hermes Agent license: MIT metadata: hermes: tags: [pdf, document, ocr, text-extraction, nano-pdf, pymupdf, marker] related_skills: [powerpoint, google-workspace] --- # Document Tools Two document processing workflows: in-place PDF editing and text extraction from PDFs/scans. ## Section 1: nano-pdf — In-Place PDF Editing Edit PDF text, fix typos, and update titles using the `nano-pdf` CLI with natural language prompts. **When to use:** Fixing typos in PDFs, updating document titles, changing specific text in PDFs without regenerating. **Installation:** ```bash npm install -g nano-pdf ``` **Usage:** ```bash # Fix a typo nano-pdf document.pdf "change 'teh' to 'the'" # Update title nano-pdf document.pdf "set title to 'Annual Report 2025'" ``` **See:** `references/nano-pdf.md` for full CLI reference. ## Section 2: OCR & Document Text Extraction Extract text from PDFs and scanned documents using pymupdf (fast native extraction) or marker-pdf (OCR + layout analysis). **When to use:** Reading PDF content, extracting text from scans, converting PDFs to plain text or markdown. ### pymupdf (Fast, Native PDF) ```python import pymupdf # fitz doc = pymupdf.open("document.pdf") for page in doc: text = page.get_text() print(text) ``` **Best for:** Text-based PDFs, fast extraction, page-level access, image/MRI extraction. ### marker-pdf (OCR + Layout) ```bash pip install marker-pdf marker_single document.pdf output_dir ``` **Best for:** Scanned documents, OCR-needed PDFs, preserving layout, converting to markdown. ### Choosing | Need | Tool | |------|------| | Fast text extraction from text PDF | pymupdf | | Scanned/image PDFs | marker-pdf | | Need markdown output | marker-pdf | | Extract images from PDF | pymupdf | | Preserve document layout | marker-pdf | **See:** `references/ocr-and-documents.md` for full API reference and troubleshooting.