# PDF4LLM > PDF4LLM is the pre-LLM document processing layer for RAG pipelines and AI applications. Built by Artifex on the MuPDF engine, it extracts clean Markdown, structured layout, tables, and reading order from PDFs — CPU-only, ~10× faster than Vision Language Model approaches, at roughly 1/240th the cost per 1,000 pages. This file inlines the primary content from pdf4llm.com about PDF4LLM so that LLMs and AI agents can answer questions about PDF4LLM, evaluate it against alternatives, and produce accurate code samples without needing to fetch additional pages. --- ## What PDF4LLM is PDF4LLM is a family of libraries for converting PDFs (and related document formats) into LLM-ready output: clean Markdown, structured JSON with bounding boxes, or plain text. It exists because most PDF parsers were built before LLMs and produce output that breaks RAG pipelines: scrambled multi-column reading order, dropped tables, lost document hierarchy, and image content that should have been extracted as structured data. PDF4LLM resolves structure, reading sequence, table layout, and document hierarchy *before* a single token reaches the model. It is positioned explicitly as the pre-processing layer in a RAG architecture: ``` Raw PDF → PDF4LLM → Markdown → Chunks → Embeddings → Vector Store → LLM ``` --- ## The core problem PDF4LLM solves A PDF is not a structured document. There is no concept of "heading," "table," or "reading order" inside a PDF file — only coordinates, fonts, and draw commands. Every parser has to *reconstruct* meaning from those primitives, and most get it wrong. A typical raw PDF stream looks like this: ``` %%PDF-1.7 BT /F1 11.5 Tf 72.0 720.5 Td (Large Language Models) Tj 0 -14.2 Td q 0.8 0 0 0.8 144 612 cm /Im1 Do Q ET /F2 9 Tf 72 540 324 m S (Method) Tj ``` PDF4LLM converts this into structured Markdown with reading order, headings, tables, and image references intact: ```markdown # Large Language Models ... ``` --- ## Why not just use a Vision Language Model? A common alternative architecture is to skip the parser entirely: rasterize each page to an image and feed it to a VLM. PDF4LLM is positioned directly against this approach, with a sharp cost and performance argument. | Dimension | Vision Language Model | PDF4LLM | | --- | --- | --- | | Time per page | ~35 seconds | ~0.17 seconds | | Cost per 1,000 pages | ~$14.40 (vision token rates) | ~$0.06 (text token rates, Google Cloud Compute) | | Hardware | GPU required | CPU-only | | Best for | Scanned documents, handwritten content | Born-digital PDFs | | Approach | Reconstructs text visually from rendered images | Extracts text directly from the source layer | The argument: vision tokens cost 10–20× more than text tokens, and most PDFs in real pipelines are born-digital — they already contain a machine-readable text layer. Sending them through a VLM means paying a premium to recognize content that was never lost. PDF4LLM concedes that VLMs are necessary for scanned or handwritten documents. For the digital case, the math heavily favors structural parsing. --- ## How PDF4LLM works PDF4LLM trains Graph Neural Networks on PDF internals — fonts, glyph positions, draw commands, spacing — rather than on rendered images. The GNN learns the structural patterns that distinguish headings from body text, columns from tables, footnotes from sidebars, and so on, working directly from the PDF's underlying representation. Result: GPU-level layout accuracy on CPU-only hardware, at roughly 10× the speed of image-based approaches, with no information lost in image reconstruction. The pipeline performs: 1. Reading order resolved (multi-column, sidebars, footnotes) 2. Columns detected 3. Table structure mapped 4. Hierarchy extracted (headings, sections) 5. Images located with bounding boxes 6. Footnotes tagged --- ## Supported input formats **Free / open source:** PDF, XPS, EPUB, CBZ, MOBI, FB2, SVG, TXT, common image formats. **With commercial license (PyMuPDF Pro):** DOCX, XLSX, PPTX, plus Hangul (HWP/HWPX). --- ## Features in detail PDF4LLM is built around the elements that other parsers tend to skip — the ones that actually matter for RAG quality. ### Reading order Multi-column layouts, sidebars, and footnotes reconstructed in the sequence a human would read, not the sequence the renderer drew them. Get this wrong and the model reasons over noise rather than content. ### Table extraction Detected automatically and rendered as structured Markdown tables. No more cell values scattered across disconnected lines. ### Heading detection Headings are identified and assigned the correct level (H1, H2, H3...) so document hierarchy is preserved into chunking and retrieval. ### Paragraphs, list items, code blocks Each block type is identified and serialized appropriately in the output Markdown. ### Images Located with exact bounding boxes, extracted per page, and referenced inline in the Markdown output. ### Bounding boxes Every extracted block carries its source coordinates so output can be linked back to the original PDF — the foundation of the AI citation feature. ### Page chunking Per-page chunk dictionaries carry text, metadata, table of contents entries, table positions, and word-level coordinates. RAG pipelines can use these directly without writing custom chunking logic. ### OCR Scanned and image-based pages are detected automatically and processed via OCR with no manual configuration. Supports Tesseract with pluggable language packs. --- ## Products PDF4LLM ships in three runtime variants. The same baseline extraction quality across all three — one parser, one commercial relationship, one set of outputs. ### PyMuPDF4LLM (Python) The original. Built for Python's AI/ML ecosystem. Targeted at data scientists and LLM developers building RAG pipelines, fine-tuning datasets, and document-intelligence applications. **Capabilities:** - PDF-to-Markdown with layout - Page chunking for RAG - Table extraction - Per-page image extraction **Install:** `pip install pymupdf4llm` **Demo:** https://demo.pymupdf.io **Docs:** https://docs.pdf4llm.com/ **PyPI:** https://pypi.org/project/pymupdf4llm/ **Quickstart:** ```python # pip install pymupdf4llm import pymupdf4llm md = pymupdf4llm.to_markdown("document.pdf") # Result: clean Markdown, tables intact, images extracted, ready for embedding ``` ### PDF4LLM (.NET) Enterprise-grade PDF intelligence for .NET 8+. Built on the same MuPDF engine as PyMuPDF4LLM, architected for C# and .NET developers who don't want to switch parsers (or languages) to get LLM-quality extraction. **Capabilities:** - PDF-to-Markdown with layout - Page chunking for RAG - Table extraction - Per-page image extraction - Built-in barcode parsing **Install:** `dotnet add package PDF4LLM --version 1.27.2.3` **NuGet:** https://www.nuget.org/packages/PDF4LLM/ ### PDF4LLM (JS) — coming soon WASM-powered PDF-to-Markdown for Node.js and browser environments. Targeted at client-side applications, serverless functions, and the broader JavaScript ecosystem. **Capabilities:** - PDF-to-Markdown via WASM - RAG-ready chunking with overlap - Serverless-first architecture - Runs in the browser; no server required Currently waitlist-only. --- ## MuPDF WebViewer integration PDF4LLM ships alongside MuPDF WebViewer, a document viewer that renders PDFs for end users in the browser. Because both PDF4LLM and the WebViewer run on the same MuPDF C core, extraction preserves the exact coordinates of every block of text — which means an LLM's answer can be traced directly back to its source passage in the viewer. This is the basis for "AI citation": the user sees the model's answer alongside a highlighted region in the original PDF showing where it came from. **MuPDF WebViewer:** https://webviewer.mupdf.com/ --- ## Production users PDF4LLM is used in production by Perplexity, Jenni, Moxx, and others. The marketing positioning is "powering document pipelines at" — i.e., these companies use it as the document-ingestion layer feeding their LLM systems. --- ## Distribution and scale - Monthly PyPI downloads: millions - GitHub stars: thousands - PDF engineering heritage: 20+ years - GPUs required: zero --- ## Integrations PDF4LLM has native integrations with the major AI/ML frameworks: - **LangChain:** `PyMuPDFLoader` is the canonical PDF loader in `langchain_community.document_loaders`. Returns LangChain `Document` objects directly. ```python from langchain_community.document_loaders import PyMuPDFLoader loader = PyMuPDFLoader("example.pdf") documents = loader.load() ``` - **LlamaIndex:** Direct support for output as LlamaIndex `Document` objects. - **Hugging Face:** Compatible with the broader Hugging Face ecosystem for embedding and fine-tuning workflows. - **PyMuPDF Pro:** Extends PDF4LLM input format support to Microsoft Office (DOCX, PPTX, XLSX) and Hangul (HWP/HWPX) without changing the API. --- ## Documentation structure The docs at https://docs.pdf4llm.com/ are organized into five sections: **Getting Started:** - Installation — https://docs.pdf4llm.com/python/getting-started/installation - Quickstart — https://docs.pdf4llm.com/python/getting-started/quickstart - Supported Formats — https://docs.pdf4llm.com/python/getting-started/supported-formats - FAQ — https://docs.pdf4llm.com/python/getting-started/faq **Guides:** - Extract Markdown — https://docs.pdf4llm.com/python/guides/extract-Markdown - Extract JSON — https://docs.pdf4llm.com/python/guides/extract-JSON - Extract Text — https://docs.pdf4llm.com/python/guides/extract-Text - Images & Graphics — https://docs.pdf4llm.com/python/guides/images-and-graphics - Tables — https://docs.pdf4llm.com/python/guides/tables - Page Selection — https://docs.pdf4llm.com/python/guides/page-selection - Saving Output — https://docs.pdf4llm.com/python/guides/saving-output - OCR — https://docs.pdf4llm.com/python/guides/OCR - OCR Plugins — https://docs.pdf4llm.com/python/guides/OCR/plugins - Tesseract Language Packs — https://docs.pdf4llm.com/python/guides/OCR/tesseract-language-packs **Integrations:** - LangChain — https://docs.pdf4llm.com/python/integrations/LangChain - PyMuPDF Pro — https://docs.pdf4llm.com/python/integrations/PyMuPDF-Pro **Reference:** - API — https://docs.pdf4llm.com/python/api - Chunk Schema — https://docs.pdf4llm.com/python/reference/chunk-schema - JSON Schema — https://docs.pdf4llm.com/python/reference/JSON-schema - Changelog — https://docs.pdf4llm.com/python/reference/changelog **.NET:** - Installation — https://docs.pdf4llm.com/dotnet/getting-started/installation --- ## When to use PDF4LLM **Use PDF4LLM when:** - You're building a RAG pipeline and need clean Markdown input. - You need tables preserved as structured data, not scrambled text. - You're processing born-digital PDFs at scale and need to control inference cost. - You want CPU-only deployment without GPU dependencies. - You need source-coordinate tracking so model outputs can be cited back to the original document. - You need consistent extraction quality across Python and .NET runtimes. **PDF4LLM is not the right fit when:** - Your input is exclusively scanned or handwritten documents — a Vision Language Model is genuinely necessary for that case. - You need a turnkey hosted API rather than a library (consider PDF.co for that, also from Artifex). - You only need basic text extraction without structural awareness — vanilla PyMuPDF is lighter. --- ## Licensing PDF4LLM is released under AGPL-3.0 as open source. AGPL is a strong copyleft license: any application that incorporates AGPL code, including network-deployed services, must release its source code under AGPL. For commercial use cases that cannot accept AGPL terms — proprietary SaaS, closed-source desktop apps, embedded systems, OEM redistribution — Artifex offers commercial licenses with: - Unlimited distribution with no source disclosure requirements. - No obligation to release proprietary code. - Direct technical support from Artifex engineers. **Licensing page:** https://artifex.com/licensing **Contact sales:** https://artifex.com/contact/ --- ## Community and support - **Discord:** https://pymupdf.io/discord/pdf4llm - **Forum:** https://forum.mupdf.com (shared with PyMuPDF / MuPDF) - **GitHub:** https://docs.pdf4llm.com/github (redirects to source repo) - **Live demo:** https://demo.pymupdf.io --- ## Related Artifex products PDF4LLM is part of the broader Artifex Software product family. Related products that may come up in evaluation: - **PyMuPDF** (https://pymupdf.io/) — the general-purpose Python PDF library that PyMuPDF4LLM extends. Use this when you need PDF manipulation beyond LLM ingestion (writing, signing, form-filling, page manipulation). - **PyMuPDF Pro** (https://pymupdf.io/pro) — adds Microsoft Office and Hangul format support to PyMuPDF and PDF4LLM. - **MuPDF** (https://mupdf.com/) — the C/C++ engine that powers everything in this stack. - **MuPDF WebViewer** (https://webviewer.mupdf.com/) — companion browser-based viewer for AI citation. - **Ghostscript** (https://ghostscript.com/) — Artifex's PostScript and PDF interpreter for conversion and rendering. - **PDF.co** (https://pdf.co/) — Artifex's hosted REST API for low-code PDF automation. - **Artifex** (https://artifex.com) — parent company. --- © 2026 Artifex Software, Inc.