pdfmux vs PyMuPDF — extraction pipeline or low-level library?
Direct answer: PyMuPDF (fitz) is a low-level PDF library — fast, AGPL-3.0 licensed, and it hands you raw text with coordinates. pdfmux is a self-healing extraction pipeline that uses PyMuPDF internally for digital pages but routes tables to Docling, scanned pages to OCR, and audits every page for quality — then ships the result as clean Markdown or JSON under MIT. On the opendataloader-bench of 200 real-world PDFs, pdfmux scores 0.903 overall (reading order 0.920, tables 0.911); the PyMuPDF-based wrapper benchmarked in that suite, pymupdf4llm, scores 0.802 (reading order 0.905, tables 0.612). Pick PyMuPDF directly when you need raw speed or low-level PDF manipulation (merge, split, redact). Pick pdfmux when you need structured, LLM-ready output without AGPL licensing.
pdfmux vs PyMuPDF: which PDF extraction library should you use?
PyMuPDF (also known as fitz) is one of the most established PDF libraries in the Python ecosystem — 11,100+ GitHub stars as of this writing — with deep low-level PDF access: text, images, fonts, annotations, forms, and page rendering. pdfmux is a newer tool built for a narrower, more specific job: turning PDFs into clean structured output for AI and RAG pipelines, without the post-processing PyMuPDF’s raw output requires.
They overlap at exactly one point — extracting text from a PDF — and diverge everywhere else. If you’re building a RAG pipeline, document ingestion system, or any application where you need reliable markdown or structured JSON from PDFs, pdfmux gets you there with fewer lines of code and better results on complex layouts. If you need to merge, split, redact, or render PDFs, PyMuPDF is still the tool for the job — pdfmux doesn’t do any of that.
Feature comparison
| Feature | pdfmux | PyMuPDF |
|---|---|---|
| Text extraction | Structured markdown/JSON | Raw text with coordinates |
| Table extraction | Built-in, routed to Docling | Basic, requires post-processing |
| Layout preservation | Automatic reading order | Manual layout analysis needed |
| Output formats | Markdown, JSON, structured | Text, HTML, XML, dict |
| LLM/RAG optimization | Native chunking support | Requires pymupdf4llm wrapper |
| OCR for scanned pages | Built-in (pdfmux[ocr]) |
None — returns empty text silently |
| PDF manipulation (merge/split/redact) | Not supported | Core strength |
| Page rendering to image | Not supported | Core strength, pixel-perfect |
| Installation size | Lightweight (~15-20 MB) | Heavy (~30 MB, C bindings) |
| License | MIT | AGPL-3.0 |
| API complexity | 3-line extraction | Verbose, low-level API |
Benchmark comparison (opendataloader-bench, 200 real-world PDFs)
Every number below is pulled directly from Best PDF extraction library for Python in 2026, which re-ran the full opendataloader-bench suite on 2026-05-19. Raw PyMuPDF isn’t benchmarked standalone in that suite — it has no native Markdown output, so the comparable entry is pymupdf4llm, the official wrapper that turns PyMuPDF’s raw text into LLM-ready markdown. That’s the row below.
| Metric | pdfmux | pymupdf4llm |
|---|---|---|
| Overall score | 0.903 (#2 of 8 engines) | 0.802 |
| Reading order (NID) | 0.920 | 0.905 |
| Table extraction (TEDS) | 0.911 | 0.612 |
| Heading structure (MHS) | 0.847 | n/a (not separately scored) |
| License | MIT | AGPL-3.0 |
| GPU required | No | No |
The gap is almost entirely tables: pymupdf4llm’s 0.612 TEDS score reflects that PyMuPDF has no real table model — it reconstructs tables from text positions, which breaks down on merged cells, nested headers, and multi-page tables. pdfmux routes any page it classifies as table-heavy to Docling before falling back to PyMuPDF, which is why its table score (0.911) actually beats Docling run alone (0.887) in the same benchmark.
Where raw PyMuPDF wins outright is speed: it processes pages in roughly 0.01s each, 10-50x faster than pdfmux’s standard pipeline on the same hardware, because it’s doing a single lightweight pass instead of classifying, routing, and auditing. If your corpus is known-clean, known-digital, and speed is the only thing that matters, that gap is real and worth using.
When to use PyMuPDF
PyMuPDF is the right choice when you need:
- Low-level PDF manipulation — merging, splitting, annotating, redacting, or watermarking PDFs. pdfmux doesn’t do any of this; it’s extraction-only.
- Raw speed over accuracy — processing millions of simple, single-column documents where 0.01s/page matters more than table fidelity.
- Pixel-perfect rendering — converting PDF pages to images at high fidelity, a common need for thumbnail generation or visual QA.
- Complete PDF access — inspecting fonts, metadata, embedded files, encryption, and other PDF internals.
- AGPL-compatible projects — your project already uses AGPL, or you’re willing to buy Artifex’s commercial license for proprietary use.
When to use pdfmux
pdfmux is the better choice when you need:
- AI/LLM-ready output — clean markdown or structured JSON for RAG pipelines, embeddings, or document Q&A. See PDF to Markdown for RAG for the full pattern.
- Accurate table extraction — financial reports, invoices, or any document with complex tables, where PyMuPDF’s 0.612 TEDS score means roughly 4 in 10 tables come out wrong.
- Multi-column layout handling — research papers, newspapers, or documents with complex reading order.
- Silent-failure protection — PyMuPDF returns empty text on scanned pages with no warning. pdfmux’s per-page quality audit catches this and re-routes to OCR automatically.
- Commercial-friendly licensing — MIT license with no copyleft restrictions, versus AGPL-3.0’s requirement to open-source anything you distribute that links to PyMuPDF.
- Minimal integration effort — extract structured data in 3 lines of code, no post-processing needed.
The licensing question, in detail
PyMuPDF ships under AGPL-3.0. That matters more than most developers expect: AGPL’s copyleft terms extend to network use, not just distribution — if you run PyMuPDF inside a SaaS product that users interact with over a network, AGPL’s terms can require you to open-source that product’s source too, not just the code that touches PyMuPDF. Artifex, the company behind PyMuPDF, sells a commercial license specifically so companies can avoid that outcome; pricing is quote-based and not public.
pdfmux uses PyMuPDF internally as one of its extraction backends, but pdfmux itself ships under MIT. The AGPL obligation attaches to the dependency, not to code that merely calls pdfmux — this is the same boundary that lets pymupdf4llm (also AGPL, since it wraps PyMuPDF directly) differ from tools that use PyMuPDF as an internal implementation detail behind a permissively-licensed interface. If your compliance team has flagged AGPL as a blocker, that’s the practical distinction to bring them: are you linking to PyMuPDF directly, or calling a tool that happens to use it internally.
Quick code comparison
pdfmux:
from pdfmux import extract_text
text = extract_text("report.pdf")
print(text)
PyMuPDF (raw):
import fitz
doc = fitz.open("report.pdf")
for page in doc:
text = page.get_text("text")
print(text)
PyMuPDF via pymupdf4llm (closer to pdfmux’s output shape):
import pymupdf4llm
md = pymupdf4llm.to_markdown("report.pdf")
Note that none of the three raise an error on a scanned page with no embedded text — fitz.get_text() and pymupdf4llm.to_markdown() both return an empty or near-empty string silently. pdfmux is the only one of the three that flags this at extraction time and automatically re-routes the page through OCR if you’ve installed pdfmux[ocr].
Migrating from PyMuPDF to pdfmux
If you’re already using PyMuPDF for extraction (not manipulation) and want to move to pdfmux without a rewrite, the practical path is incremental: keep PyMuPDF for any code that merges, splits, redacts, or renders pages — pdfmux doesn’t replace that — and swap only the extraction call.
# Before
import fitz
doc = fitz.open("report.pdf")
text = "\n".join(page.get_text("text") for page in doc)
# After
from pdfmux import extract_text
text = extract_text("report.pdf")
For batch pipelines processing thousands of files, see batch processing PDFs in Python for the concurrency pattern pdfmux uses — it releases the GIL on PyMuPDF calls, so a thread pool scales close to linearly on a single machine, unlike ML-heavy tools that hold the GIL through model inference.
Decision matrix
| Need | Best choice | Why |
|---|---|---|
| General-purpose extraction into RAG/LLM pipelines | pdfmux | Best free overall score (0.903) on opendataloader-bench |
| Known-clean, high-volume digital PDFs | PyMuPDF directly | 10-50x faster, no routing/audit overhead |
| Table-heavy documents (financial, invoices) | pdfmux | 0.911 TEDS vs pymupdf4llm’s 0.612 |
| PDF merge/split/redact/render | PyMuPDF | pdfmux has no manipulation API |
| Mixed corpus (some scanned, some digital) | pdfmux | Automatic OCR fallback; PyMuPDF fails silently on scans |
| AGPL is a hard no for your legal team | pdfmux | MIT license, no copyleft exposure |
FAQ
Can I use PyMuPDF in a commercial product?
PyMuPDF uses the AGPL-3.0 license, which can require you to open-source your entire application if you distribute it or expose it over a network. Artifex (the company behind PyMuPDF) sells commercial licenses for proprietary use. pdfmux uses the MIT license, which allows unrestricted commercial use.
Is pdfmux faster than PyMuPDF?
No, not on raw per-page throughput — PyMuPDF’s C-based core processes a page in roughly 0.01s, which is faster than pdfmux’s standard pipeline on the same page. pdfmux can be faster for the end-to-end workflow, though, because it produces structured, ready-to-use output directly — eliminating the manual post-processing (table reconstruction, column detection) that raw PyMuPDF output requires before it’s usable.
Can pdfmux replace PyMuPDF for PDF manipulation?
No. pdfmux is focused on extraction and conversion. If you need to merge, split, annotate, redact, or render PDFs, PyMuPDF or pikepdf are the right tools. Many developers use pdfmux for extraction alongside PyMuPDF for manipulation in the same project — they’re not mutually exclusive.
Does PyMuPDF handle scanned PDFs?
No. PyMuPDF has no OCR engine, and page.get_text() returns an empty string on a scanned page with no warning — the single most common silent failure in production PDF pipelines. pdfmux’s per-page quality audit flags low-confidence pages and automatically re-extracts them via OCR if pdfmux[ocr] is installed.
How does pymupdf4llm compare to raw PyMuPDF?
pymupdf4llm is a wrapper that turns PyMuPDF’s raw text extraction into structured markdown, closer to what pdfmux outputs. On opendataloader-bench it scores 0.802 overall (reading order 0.905, tables 0.612) — better than raw PyMuPDF’s unstructured text for LLM use, but still well behind pdfmux’s 0.903, mainly on table accuracy.
Which one should a new RAG project start with?
If you don’t yet know what your incoming PDFs will look like — a mix of digital text, scanned pages, and complex tables — start with pdfmux and let its classifier route pages automatically. If you’ve profiled your corpus and know it’s uniformly clean, digital, single-column text, raw PyMuPDF is simpler and meaningfully faster.
Related reading
- Best PDF extraction library for Python in 2026 (benchmarked) — the full 8-engine opendataloader-bench comparison this post’s numbers are sourced from
- I benchmarked every PDF-to-Markdown tool. Then I built a router. — the original benchmark story behind pdfmux
- pdfmux vs PyMuPDF vs marker vs docling: 200-PDF benchmark — the full multi-tool head-to-head
- pdfmux vs PaddleOCR-VL: OCR model or extraction orchestrator? — how pdfmux compares against a single strong open-weight VLM instead of a classic library
- AWS Textract alternatives — for teams comparing pdfmux against managed cloud OCR instead of a local library
- Batch processing thousands of PDFs in Python — the concurrency pattern for high-volume extraction