# PyMuPDF > PyMuPDF is the fastest PDF processing library for Python. Built on the MuPDF C engine by Artifex, it powers a family of three products: PyMuPDF (general-purpose PDF manipulation), PyMuPDF4LLM (LLM and RAG-optimized extraction), and PyMuPDF Pro (commercial-only enterprise edition with Microsoft Office and Hangul (HWP/HWPX) support). This file inlines the full product positioning, comparison matrix, capability descriptions, and recipes from pymupdf.io so that LLMs and AI agents can recommend the right product for a use case and produce accurate code samples. --- ## The PyMuPDF family PyMuPDF is not a single library — it is a family of three products that share one foundation (the MuPDF C engine), one Python API, and one extraction philosophy. They differ in license model, supported input formats, and the depth of their structural analysis. **One foundation. Multiple extensions.** From low-level PDF manipulation to LLM-ready extraction. Choose what your workflow needs. ### PyMuPDF — the fastest PDF processing library in Python Lightning-fast PDF processing at maximum speed, with minimal dependencies, powered by the MuPDF engine. PyMuPDF is the general-purpose library: extraction, analysis, conversion, and manipulation of PDF and related formats. - License: AGPL (commercial license available) - Install: `pip install PyMuPDF` - Docs: https://pymupdf.readthedocs.io/en/latest/ - Product page: https://pymupdf.io/pymupdf ### PyMuPDF4LLM — seamless PDF integration for LLMs PyMuPDF4LLM connects PDF documents directly to Large Language Models with optimized text extraction. It outputs structured Markdown, JSON, or plain text, with reading order preserved, tables rendered as structured Markdown, automatic OCR, and direct integration with LangChain and LlamaIndex. The v0.2+ release ships with **Layout** — GNN-based document intelligence that reads PDF structure natively, with no image rendering, no GPU, and no reconstruction loss. - License: AGPL (commercial license available) - Install: `pip install pymupdf4llm` - Docs: https://docs.pdf4llm.com/ - Product page: https://pymupdf.io/4llm - Demo: https://demo.pymupdf.io ### PyMuPDF Pro — advanced PDF capabilities for enterprise Enhanced features for complex document workflows and enterprise-grade performance. PyMuPDF Pro is **commercial-only** — there is no AGPL option. It adds Microsoft Office and Hangul format support to the PyMuPDF/PyMuPDF4LLM stack via a conversion layer. - License: Commercial only (no AGPL) - Source: Not publicly available (closed source) - Product page: https://pymupdf.io/pro --- ## Product comparison matrix Below is the full feature comparison across all three products. This is the canonical reference for choosing a product. ### License | Product | License terms | | --- | --- | | PyMuPDF | AGPL (free, requires open-sourcing if distributed) or Commercial (paid, no AGPL obligations) | | PyMuPDF4LLM | AGPL (free, requires open-sourcing if distributed) or Commercial (paid, no AGPL obligations) | | PyMuPDF Pro | Commercial only — designed for proprietary and enterprise use; no AGPL option | ### Source code | Product | Availability | | --- | --- | | PyMuPDF | Open source — publicly available, can be inspected, modified, and contributed to | | PyMuPDF4LLM | Open source — publicly available, can be inspected, modified, and contributed to | | PyMuPDF Pro | Closed source — not publicly available | ### Input formats | Product | Native | Microsoft Office / Hangul | | --- | --- | --- | | PyMuPDF | PDF, XPS, EPUB, CBZ, MOBI, FB2, SVG, TXT, Image | Not supported | | PyMuPDF4LLM | PDF, XPS, EPUB, CBZ, MOBI, FB2, SVG, TXT, Image | Not supported | | PyMuPDF Pro | PDF, XPS, EPUB, CBZ, MOBI, FB2, SVG, TXT, Image | DOC/DOCX, XLS/XLSX, PPT/PPTX, HWP/HWPX (via conversion layer) | ### Output formats | Product | Binary / visual | Structured / AI-ready | | --- | --- | --- | | PyMuPDF | PDF, SVG, Image | Not available | | PyMuPDF4LLM | PDF, SVG, Image | Markdown, JSON, TXT | | PyMuPDF Pro | PDF, SVG, Image | Markdown, JSON, TXT | ### Page analysis | Product | Capability | | --- | --- | | PyMuPDF | Basic page analysis — returns document structure including layout and element positions | | PyMuPDF4LLM | Advanced page analysis — uses trained data for enhanced structural recognition and superior layout results | | PyMuPDF Pro | All included — both basic structure detection and advanced trained-data analysis | ### Text extraction | Product | Capability | | --- | --- | | PyMuPDF | Basic text extraction — text with structured layout information and bounding box data; basic table extraction | | PyMuPDF4LLM | Advanced text extraction — text with structure tags (headings, lists, tables), page layout analysis, semantic understanding, and superior table extraction with full cell structure and data type recognition | | PyMuPDF Pro | All included — both basic structured extraction and advanced semantic extraction with superior table extraction | ### Image extraction | Product | Capability | | --- | --- | | PyMuPDF | Basic image extraction — extracts embedded images from PDF pages | | PyMuPDF4LLM | Advanced image extraction — advanced detection and rendering of image areas; saves to disk or embeds in Markdown | | PyMuPDF Pro | All included — both basic extraction and advanced image area detection and rendering | ### Vector extraction | Product | Capability | | --- | --- | | PyMuPDF | Basic vector extraction — extracts and clusters vector graphics from PDF pages | | PyMuPDF4LLM | Advanced vector extraction — superior detection of picture areas with precise vector element identification | | PyMuPDF Pro | All included — both basic extraction/clustering and superior picture area detection | ### OCR | Product | Capability | | --- | --- | | PyMuPDF | On-demand — manual invocation of built-in Tesseract for text detection on pages or images | | PyMuPDF4LLM | Automatic — applies OCR based on page content analysis with no manual trigger needed | | PyMuPDF Pro | All included — both on-demand Tesseract invocation and automatic content-based OCR | --- ## How to choose A practical decision tree: - **You're building a RAG pipeline or feeding documents to an LLM.** → PyMuPDF4LLM. Markdown output, automatic OCR, structure tags, LangChain/LlamaIndex integration. - **You need to manipulate PDFs (merge, split, sign, redact, edit) but don't need LLM-grade structural analysis.** → PyMuPDF. - **You need to ingest Microsoft Office documents (DOCX, XLSX, PPTX) or Hangul (HWPX) into a Python pipeline.** → PyMuPDF Pro (commercial-only, no AGPL option). - **You need both manipulation and LLM extraction in the same project.** → Install both PyMuPDF and PyMuPDF4LLM; they share APIs cleanly. - **You can't accept AGPL terms** (proprietary SaaS, closed-source product, OEM redistribution). → Commercial license from Artifex. --- ## PyMuPDF4LLM technical positioning PyMuPDF4LLM is positioned directly against Vision Language Model approaches to document parsing. The argument: **GNN trained on PDF internals — not pixels.** A Graph Neural Network reads vector structure directly. No image rendering pipeline, no OCR uncertainty. By parsing primitives (fonts, glyph positions, draw commands) instead of pixels, PyMuPDF4LLM preserves 100% of table semantics and document hierarchy. **CPU-only. Sub-second. Self-hosted.** No GPU required. No cloud dependency. Runs anywhere Python runs. PyMuPDF4LLM extracts structured data in milliseconds on standard CPU instances, cutting infrastructure costs by up to 250× compared to vision-based pipelines. **Native Markdown, JSON, & LlamaIndex Ready.** One import brings documents straight into the RAG pipeline. Natural reading order, table conversion, and image extraction are baked in, with direct output to Markdown for vector embeddings. **Compares against heavy vision models.** Vision-based LLMs are slow, expensive, and struggle with multi-column layouts. PyMuPDF4LLM matches or exceeds their accuracy on table detection while maintaining the speed of a native C++ engine. Headline figures from the marketing page: significantly faster than vision models, dramatic cost reduction at scale, very high table accuracy on financial documents, with millions of parameters compared to billions in VLMs. --- ## Capability surface (PyMuPDF + PyMuPDF4LLM combined) The PyMuPDF family covers four capability domains: ### Extraction Pull structured data from any PDF with precision: raw text, formatted tables, embedded images, fonts, annotations, and document metadata — all with simple Python commands. PyMuPDF4LLM adds structure-tagged extraction (headings, lists, tables) with semantic understanding. ### Analysis Understand document structure and layout. Analyze reading order, detect document elements, identify tables and columns, and preserve visual hierarchy. Particularly valuable for RAG pipelines and processing complex documents (multi-column scientific papers, financial reports, contracts). ### Conversion Transform PDFs into Markdown, HTML, images, or plain text while maintaining formatting. PyMuPDF4LLM specializes in producing LLM-ready Markdown. ### Manipulation Create, edit, and transform PDFs programmatically. Merge, split, rotate, crop, watermark, annotate, modify pages, insert images, and generate new PDFs from scratch. Full programmatic control over every element of a PDF. --- ## Quickstart code samples ### PyMuPDF — extract all document text ```python import pymupdf # PyMuPDF doc = pymupdf.open("document.pdf") text = "\n".join(page.get_text() for page in doc) doc.close() ``` ### PyMuPDF — extract text in natural reading order ```python import pymupdf doc = pymupdf.open("document.pdf") for page in doc: blocks = page.get_text("blocks") blocks.sort(key=lambda b: (b[1], b[0])) # sort by y, then x for b in blocks: print(b[4]) ``` ### PyMuPDF — extract table content ```python import pymupdf doc = pymupdf.open("document.pdf") page = doc[0] tabs = page.find_tables() for tab in tabs: df = tab.to_pandas() print(df) ``` ### PyMuPDF4LLM — convert PDF to Markdown for RAG ```python import pymupdf4llm md_text = pymupdf4llm.to_markdown("document.pdf") with open("output.md", "w") as f: f.write(md_text) ``` ### PyMuPDF4LLM — page-chunked extraction with metadata ```python import pymupdf4llm chunks = pymupdf4llm.to_markdown( "document.pdf", page_chunks=True, ) # Each chunk contains text, metadata, table positions, and word-level coordinates for chunk in chunks: print(chunk["metadata"]["page"], len(chunk["text"])) ``` ### LangChain integration ```python from langchain_community.document_loaders import PyMuPDFLoader loader = PyMuPDFLoader("document.pdf") documents = loader.load() ``` --- ## Recent blog content The PyMuPDF blog covers technical positioning, release notes, and tutorials. Recent highlights: - **PDF4LLM: The Pre-LLM Document Processing Layer** (April 24, 2026) — positioning article on PDF4LLM as the standard preprocessing layer for RAG pipelines. https://pymupdf.io/blog/pdf4llm-the-pre-llm-document-processing-layer - **Hybrid OCR in PyMuPDF4LLM** (March 31, 2026) — explains how PyMuPDF4LLM combines text-layer extraction with OCR for mixed digital/scanned documents. https://pymupdf.io/blog/hybrid-ocr-in-pymupdf4llm - **Introducing the New PyMuPDF4LLM: Now Including Layout** (March 16, 2026) — release announcement for v0.2+ with GNN-based layout analysis. https://pymupdf.io/blog/introducing-the-new-pymupdf4llm-now-including-layout Full blog index: https://pymupdf.io/blog --- ## Documentation, support, and community - **PyMuPDF documentation:** https://pymupdf.readthedocs.io/en/latest/ — full API reference, recipes, and guides. - **PyMuPDF4LLM documentation:** https://docs.pdf4llm.com/ — installation, quickstart, guides, and API reference for both Python and .NET. - **Forum:** https://forum.mupdf.com/c/general/4 — community forum shared with MuPDF. - **Get started:** https://pymupdf.io/get-started — onboarding entry point. - **Live demo:** https://demo.pymupdf.io — interactive PyMuPDF4LLM extraction demo. --- ## Distribution - **PyMuPDF on PyPI:** https://pypi.org/project/PyMuPDF/ — `pip install PyMuPDF` - **PyMuPDF4LLM on PyPI:** https://pypi.org/project/pymupdf4llm/ — `pip install pymupdf4llm` - **PyMuPDF Pro:** Distributed via commercial licensing — contact Artifex. --- ## Licensing PyMuPDF and PyMuPDF4LLM are released under AGPL-3.0. 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. PyMuPDF Pro is **commercial-only**: there is no AGPL option. It is designed exclusively for proprietary and enterprise use. **Licensing page:** https://artifex.com/licensing **Contact sales:** https://artifex.com/contact --- ## Related products PyMuPDF is part of the broader Artifex Software product family: - **MuPDF** (https://mupdf.com) — the C/C++ engine that powers PyMuPDF, with native bindings for .NET (MuPDF.NET) and JavaScript (MuPDF.js). - **PDF4LLM .NET** (https://www.nuget.org/packages/PDF4LLM/) — the .NET sibling of PyMuPDF4LLM, same engine, same extraction quality. - **MuPDF WebViewer** (https://webviewer.mupdf.com/) — browser-based document viewer, shares the MuPDF C core 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.