Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastpdfium

fastpdfium adds a small ergonomic layer over pypdfium2, the Python binding for PDFium, the PDF engine Chrome uses. It gives you page-tagged text extraction, content-based search whose hits carry their matched text and surroundings, previews with matches highlighted on the rendered page, and simple authoring (text, boxes, images) that pypdfium2 alone doesn’t expose. Pages get a _repr_png_, so a bare PdfPage expression displays itself in any rich frontend: Jupyter, solveit, or an AI-driven kernel.

License

PDFium and pypdfium2 are permissively licensed, so fastpdfium is plain Apache-2.0. If you need structured layout extraction, redaction, or richer authoring, PyMuPDF does more at the cost of AGPL; see fastfitz.

Install

pip install fastpdfium

fastpdfium also registers a pyskill, so AI kernels with pyskills discovery gain PDF reading and editing automatically when fastpdfium is installed.

Quick start

import pypdfium2 as pdfium
from fastpdfium.core import *

pdf = pdfium.PdfDocument('some.pdf')
print(pdf.text(pages=[0]))                 # cheap first: page-tagged text
ms = pdf.search('Delaware')                # content-based matches across the document
ms[0].ctx()                                # the hit marked inline: '...a **Delaware** corporation...'
ms[0].page.preview('Delaware', crop=True)  # see it highlighted on the page
pdf[0]                                     # bare page displays itself

doc = pdfium.PdfDocument.new()             # authoring from nothing
pg = doc.new_page()
pg.insert_text('Hello PDF', 72, 92, size=14)
doc.save('hello.pdf')

About

An ergonomic, fastai-style wrapper over pypdfium2 for reading, searching, previewing, and editing PDFs

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages