Some text some message..
Back What is PyMuPDF (fitz) 07 Aug, 2025

fitz is the name of a Python module that is part of the PyMuPDF library — a powerful toolkit for working with PDF files and other document types.


🔹 What is PyMuPDF (fitz)?

  • PyMuPDF is the actual library name.

  • fitz is the internal module name you use to import it in Python.

📌 import fitz is the same as import PyMuPDF, because the original name of the underlying C++ library was MuPDF, and the Python binding kept fitz as the module name.


🔹 What can fitz (PyMuPDF) do?

With fitz, you can:

  • Extract text, images, and metadata from PDF and other supported documents.

  • Render pages as images (PNG, JPEG, etc.).

  • Merge, split, or modify PDF files.

  • Add or extract annotations, links, or bookmarks.

  • Search for text in PDFs.

  • Work with other formats like XPS, OpenXPS, CBZ, and EPUB.


🔹 Example Usage

import fitz  # PyMuPDF

doc = fitz.open("example.pdf")  # Open the PDF

for page in doc:
    text = page.get_text()
    print(text)

doc.close()

🔹 Installation

To install PyMuPDF:

pip install pymupdf

Then in code:

import fitz  # this is how you access PyMuPDF

🔹 Why is it called fitz?

The name comes from the original internal class in MuPDF source code, fitz.c. Even though the library was renamed PyMuPDF for Python, the import name stayed as fitz for compatibility and legacy reasons.