fastfitz adds a small ergonomic layer over
PyMuPDF: page-tagged text extraction,
document-level search returning (page, rects) pairs, and search-driven
visual previews (pg.preview('some clause') renders just the matched
region). Pages get a _repr_png_, so a bare Page expression displays
itself in any rich frontend – Jupyter, solveit, or an AI-driven kernel.
PyMuPDF is AGPL-3.0, and therefore fastfitz is AGPL-3.0 too. Installing it is an explicit opt-in to that license; if AGPL doesn’t work for your use, Artifex sells commercial PyMuPDF licenses, or see permissively-licensed alternatives like pypdfium2.
pip install fastfitzfastfitz also registers a pyskill, so AI kernels with pyskills discovery gain PDF viewing automatically when fastfitz is installed.
import fitz
from fastfitz.core import *
pdf = fitz.open('some.pdf')
print(pdf.text(pages=[0])) # cheap first: page-tagged text
hits = pdf.search_for('Delaware') # [(page, rects)] across the document
hits[0][0].preview('Delaware') # render just the matched region
pdf[0] # bare page displays itself