talira

A high performance Python library for data extraction, analysis, conversion & manipulation of PDF (and other) documents.

open sourceAGPL-3.0-onlyself-hostablefree

PyMuPDF is the Python binding to MuPDF, Artifex's C PDF and document engine. It renders pages to images, extracts text, words, tables, images and vector graphics with coordinates, edits and annotates PDFs, fills and creates form fields, redacts, merges and splits, and opens XPS, EPUB, MOBI, CBZ, SVG and images too. Since PyMuPDF 2.0 it also holds what was pymupdf4llm: machine-learning layout analysis on CPU turns PDFs and Office files into Markdown, JSON or text for RAG and agents, with OCR through RapidOCR or Tesseract. It is very fast compared with pure-Python libraries. It is dual-licensed: GNU AGPL-3.0 for open-source use, or a paid commercial licence from Artifex for proprietary or closed-source products (including SaaS that can't meet the AGPL).

Problems it solves

  • pypdf takes minutes to pull the text out of a few thousand pages
  • render PDF pages to PNG thumbnails in Python without shelling out to another program
  • get every word on the page with its x/y coordinates so I can find where a label is
  • black out sensitive text in a PDF for real, not just draw a box over it
  • add highlights, notes and stamps to a PDF from a Python script
  • fill in and read the values of form fields in a PDF using Python
  • extract the embedded images from a PDF at their original resolution
  • convert PDFs to Markdown for an LLM without paying for a cloud API
  • open EPUB and XPS files with the same code I use for PDFs
  • one Python library that can read, edit, render and write PDFs instead of four
  • insert text and draw shapes onto an existing PDF page
  • OCR only the scanned pages while turning PDFs into Markdown for RAG
  • Markdown with headings and tables from PDFs for a LlamaIndex pipeline

Features

  • render pages of all supported formats to images
  • extract text, Markdown, tables and vector graphics
  • write text and draw vector graphics on PDF pages
  • handles damaged and encrypted PDFs and incremental updates
  • annotations and form field creation, reading and updating
  • redaction, optional content, font subsetting
  • Tesseract OCR API
  • merge PDFs with other document types
  • opens PDF, XPS, EPUB, MOBI, FB2, CBZ, SVG, TXT, MD and images; DOCX/XLSX/PPTX/HWPX via HTML conversion

Limitations

  • Can't digitally sign PDFs or create signature fields1
  • Not thread-safe: use multiple processes instead of threads23

Ways to run it

PyMuPDF (AGPL)

You run it, AGPL-3.0-only

free3

Only in this edition

  • PDF processing library
  • runs without a GPU

Not included

  • Office formats (PyMuPDF Office)34
  • support (community only)5
  • use in proprietary software or networked services without sharing source5

You arrange

  • share your source under the AGPL, including for networked deployments
  • keep the producer notice in generated PDFs

Self-hosting docs

PyMuPDF commercial licence (Artifex)

You run it, under a commercial licence

no published prices; contact Artifex sales (OEM distribution or subscription, per-copy cost with a quarterly minimum fee)56

Only in this edition

  • release from AGPL obligations (proprietary, SaaS, OEM, internal use)
  • direct engineering support
  • redistribution rights for embedded products

You arrange

  • annual distribution-volume reporting for OEM distribution

Self-hosting docs

PyMuPDF Office

You run it, under a commercial licence

no published price; free trial key for a limited time4

Only in this edition

  • Word, Excel, PowerPoint and HWP/HWPX to PDF, Markdown or JSON

You arrange

  • a licence key passed to pymupdf.office.unlock()

Self-hosting docs

Capabilities

Has official SDKsplan not known

Alternatives

The same job

These do what PyMuPDF does.

  1. pypdfium2 Python bindings to PDFium, reasonably cross-platform
  2. Apache PDFBox The Apache PDFBox library is an open source Java tool for working with PDF documents.
  3. MuPDF The ultimate library for managing PDF documents
  4. pdfplumber Plumb a PDF for detailed information about each char, rectangle, line, et cetera — and easily extract text and tables.
  5. pdf-lib Create and modify PDF documents in any JavaScript environment.
  6. Apryse SDK (WebViewer) Document SDKs for viewing, editing and extracting data across 100+ formats

Compare PyMuPDF with the top 3