Welcome to PyMuPDF¶
PyMuPDF is a layout-aware document engine for AI and a feature-rich Python toolkit for extracting, rendering and editing PDFs and other documents. Since version 2.0, its ML-based layout analysis turns PDFs and Office files into high-quality Markdown for RAG and agents, running fast on CPU and grounding every result to its source page.
PyMuPDF is hosted on GitHub and registered on PyPI.
Want to extract text from every scanned PDF added to a Google Drive folder?
See the Make workflow with PDF.co for an automated solution.
This documentation covers all versions up to 2.2.
About
User Guide
How to Guide
- Opening Files
- Converting Files
- Compressing Files
- Text
- How to Extract all Document Text
- How to Extract Text as Markdown
- How to Extract Key-Value Pairs from a Page
- How to Extract Text from within a Rectangle
- How to Extract Text in Natural Reading Order
- How to Extract Table Content from Documents
- How to Mark Extracted Text
- How to Mark Searched Text
- How to Mark Non-horizontal Text
- How to Analyze Font Characteristics
- How to Insert Text
- How to Extract Text with Color
- Images
- How to Make Images from Document Pages
- How to Increase Image Resolution
- How to Create Partial Pixmaps (Clips)
- How to Zoom a Clip to a GUI Window
- How to Create or Suppress Annotation Images
- How to Extract Images: Non-PDF Documents
- How to Extract Images: PDF Documents
- How to Handle Image Masks
- How to Make one PDF of all your Pictures (or Files)
- How to Create Vector Images
- How to Convert Images
- How to Use Pixmaps: Gluing Images
- How to Use Pixmaps: Making a Fractal
- How to Interface with NumPy
- How to Add Images to a PDF Page
- How to Use Pixmaps: Checking Text Visibility
- Annotations
- Drawing and Graphics
- Stories
- How to Add a Line of Text with Some Formatting
- How to use Images
- How to Read External HTML and CSS for a Story
- How to Output Database Content with Story Templates
- How to Integrate with Existing PDFs
- How to Make Multi-Columned Layouts and Access Fonts from Package pymupdf-fonts
- How to Make a Layout which Wraps Around a Predefined “no go area” Layout
- How to Output an HTML Table
- How to Create a Simple Grid Layout
- How to Generate a Table of Contents
- How to Display a List from JSON Data
- Using the Alternative
Story.write*()functions
- Journalling
- Multiprocessing
- Optional Content Support
- Low-Level Interfaces
- Common Issues and their Solutions
API Reference
- Classes
- JSON Schema
- Operator Algebra for Geometry Objects
- Low Level Functions and Classes
- Glossary
- Constants and Enumerations
- Constants
- Document Permissions
- PDF Optional Content Codes
- PDF encryption method codes
- Font File Extensions
- Text Alignment
- Font Properties
- Text Extraction Flags
- Link Destination Kinds
- Link Destination Flags
- Annotation Related Constants
- Widget Constants
- PDF Standard Blend Modes
- Stamp Annotation Icons
- Pixmap Transformations
- Color Database
Integrations
Other
