PDF and Document Text Extraction with Hermes Agent
Extract text from PDFs/scans (pymupdf, marker-pdf).
Written by Neura Market from the official Hermes Agent documentation for Ocr And Documents. Commands, paths, and version numbers are reproduced from the source unchanged.
Read the official documentationThis guide covers the ocr-and-documents skill bundled with Hermes Agent, which extracts text from PDFs and scanned documents. You will learn when to use web_extract for remote files, how to choose between the lightweight pymupdf and the heavy-duty marker-pdf for local extraction, and how to split, merge, and search PDFs. This is the skill you reach for when you need the words out of a PDF, whether it is a clean digital file or a stack of scans.
What it does
The skill turns PDFs into readable text. For a text-based PDF, pymupdf pulls the text layer directly, fast and with no model downloads. For scanned documents, where the text is trapped in images, marker-pdf runs OCR to recognize characters across 90+ languages. It also handles tables, equations, code blocks, forms, and reading order, which plain text extraction misses. The skill also covers splitting, merging, and searching PDFs using pymupdf's native capabilities.
Before you start
This skill is bundled with Hermes Agent, so it is installed by default. It works on Linux, macOS, and Windows. You need Python and pip to install the extractors. pymupdf is about 25MB and installs quickly. marker-pdf is a different beast: it pulls in PyTorch and models, totaling 3-5GB, and downloads about 2.5GB of models to ~/.cache/huggingface/ on first use. Check your free disk space before installing it. The helper scripts accept --help for full usage.
Step 1: Remote URL Available?
If the document has a URL, always try web_extract first. It converts PDFs to markdown via Firecrawl with no local dependencies. This is the fastest path for online reports, papers, or any hosted file.
web_extract(urls=["https://arxiv.org/pdf/2402.03300"])
web_extract(urls=["https://example.com/report.pdf"])
Only fall back to local extraction when the file is local, web_extract fails, or you need batch processing.
Step 2: Choose Local Extractor
The choice comes down to what is in the PDF. The table below summarizes the capabilities.
| Feature | pymupdf (~25MB) | marker-pdf (~3-5GB) |
|---|---|---|
| Text-based PDF | ✅ | ✅ |
| Scanned PDF (OCR) | ❌ | ✅ (90+ languages) |
| Tables | ✅ (basic) | ✅ (high accuracy) |
| Equations / LaTeX | ❌ | ✅ |
| Code blocks | ❌ | ✅ |
| Forms | ❌ | ✅ |
| Headers/footers removal | ❌ | ✅ |
| Reading order detection | ❌ | ✅ |
| Images extraction | ✅ (embedded) | ✅ (with context) |
| Images → text (OCR) | ❌ | ✅ |
| EPUB | ✅ | ✅ |
| Markdown output | ✅ (via pymupdf4llm) | ✅ (native, higher quality) |
| Install size | ~25MB | ~3-5GB (PyTorch + models) |
| Speed | Instant | ~1-14s/page (CPU), fast on GPU |
Decision: Use pymupdf unless you need OCR, equations, forms, or complex layout analysis.
If the user needs marker capabilities but the system lacks ~5GB free disk, explain the tradeoff:
"This document needs OCR/advanced extraction (marker-pdf), which requires ~5GB for PyTorch and models. Your system has [X]GB free. Options: free up space, provide a URL so I can use web_extract, or I can try pymupdf which works for text-based PDFs but not scanned documents or equations."
pymupdf (lightweight)
Install it with pip:
pip install pymupdf pymupdf4llm
Via helper script:
python scripts/extract_pymupdf.py document.pdf # Plain text
python scripts/extract_pymupdf.py document.pdf --markdown # Markdown
python scripts/extract_pymupdf.py document.pdf --tables # Tables
python scripts/extract_pymupdf.py document.pdf --images out/ # Extract images
python scripts/extract_pymupdf.py document.pdf --metadata # Title, author, pages
python scripts/extract_pymupdf.py document.pdf --pages 0-4 # Specific pages
Inline:
python -c "
import pymupdf
doc = pymupdf.open('document.pdf')
for page in doc:
print(page.get_text())
"
The helper script gives you options for markdown, tables, images, metadata, and specific pages. The inline version is a quick one-liner for a plain text dump.
marker-pdf (high-quality OCR)
Check disk space first, then install:
# Check disk space first
python scripts/extract_marker.py --check
pip install marker-pdf
Via helper script:
python scripts/extract_marker.py document.pdf # Markdown
python scripts/extract_marker.py document.pdf --json # JSON with metadata
python scripts/extract_marker.py document.pdf --output_dir out/ # Save images
python scripts/extract_marker.py scanned.pdf # Scanned PDF (OCR)
python scripts/extract_marker.py document.pdf --use_llm # LLM-boosted accuracy
CLI (installed with marker-pdf):
marker_single document.pdf --output_dir ./output
marker /path/to/folder --workers 4 # Batch
The helper script outputs markdown by default, with options for JSON, saving images, and LLM-boosted accuracy. The CLI gives you a single-file mode and a batch mode with parallel workers.
Arxiv Papers
For research papers, the skill offers three patterns:
# Abstract only (fast)
web_extract(urls=["https://arxiv.org/abs/2402.03300"])
# Full paper
web_extract(urls=["https://arxiv.org/pdf/2402.03300"])
# Search
web_search(query="arxiv GRPO reinforcement learning 2026")
Use the abstract page for a quick summary, the PDF for the full text, and web_search to find papers in the first place.
Split, Merge & Search
pymupdf handles these natively, so you can use execute_code or inline Python without extra dependencies.
# Split: extract pages 1-5 to a new PDF
import pymupdf
doc = pymupdf.open("report.pdf")
new = pymupdf.open()
for i in range(5):
new.insert_pdf(doc, from_page=i, to_page=i)
new.save("pages_1-5.pdf")
# Merge multiple PDFs
import pymupdf
result = pymupdf.open()
for path in ["a.pdf", "b.pdf", "c.pdf"]:
result.insert_pdf(pymupdf.open(path))
result.save("merged.pdf")
# Search for text across all pages
import pymupdf
doc = pymupdf.open("report.pdf")
for i, page in enumerate(doc):
results = page.search_for("revenue")
if results:
print(f"Page {i+1}: {len(results)} match(es)")
print(page.get_text("text"))
No extra dependencies needed, pymupdf covers split, merge, search, and text extraction in one package.
When not to use it
If you are dealing with Word documents, do not OCR them. Install python-docx instead, which parses the actual structure and is better than OCR. For PowerPoint files, use the powerpoint skill, which uses python-pptx for full create/read/edit support. For PDF manipulation like merging, splitting, forms, watermarks, or creation, see the pdf skill. This skill is specifically for text extraction, not document editing.
Limits and gotchas
web_extractis always first choice for URLs, but it only works when the file is accessible online.pymupdfcannot OCR scanned PDFs. If you feed it a scan, you get nothing.marker-pdfis heavy: 3-5GB install, plus ~2.5GB model download on first use. It is slow on CPU, about 1-14 seconds per page, but fast on GPU.read_fileauto-converts local PDFs but only reads the text layer. If you get an extraction coverage warning listing pages with no text, those are scanned images. For a few pages, render them withpdftoppm -jpeg -r 150 -f N -l N file.pdf /tmp/pageand usevision_analyzeon each image. For bulk OCR, use marker-pdf.
What pairs with this
The related skills are pdf for PDF manipulation, docx for Word documents, and powerpoint for presentations. Use this skill when you need the text out of a PDF, and the others when you need to create or edit those formats.