Metadata-Version: 2.4
Name: fastpdfium
Version: 0.0.1
Summary: An ergonomic, fastai-style wrapper over pypdfium2 for reading, searching, previewing, and editing PDFs
Author-email: fastpdfium contributors <nc@answer.ai>
License: Apache-2.0
Project-URL: Repository, https://github.com/AnswerDotAI/fastpdfium
Project-URL: Documentation, https://AnswerDotAI.github.io/fastpdfium/
Keywords: pdf,pdfium,pypdfium2
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pypdfium2
Requires-Dist: fastcore
Requires-Dist: pillow
Dynamic: license-file

# fastpdfium


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

fastpdfium adds a small ergonomic layer over
[pypdfium2](https://pypdfium2.readthedocs.io/), 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](https://github.com/AnswerDotAI/fastfitz).

## Install

``` sh
pip install fastpdfium
```

fastpdfium also registers a
[pyskill](https://answerdotai.github.io/pyskills), so AI kernels with
pyskills discovery gain PDF reading and editing automatically when
fastpdfium is installed.

## Quick start

``` python
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')
```
