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.
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 asimport PyMuPDF
, because the original name of the underlying C++ library wasMuPDF
, and the Python binding keptfitz
as the module name.
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.
import fitz # PyMuPDF
doc = fitz.open("example.pdf") # Open the PDF
for page in doc:
text = page.get_text()
print(text)
doc.close()
To install PyMuPDF:
pip install pymupdf
Then in code:
import fitz # this is how you access PyMuPDF
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.