pyropdf is a Python library, implemented in Rust, for complete control of PDF as ISO 32000-2 defines it. It keeps a document on one versioned object store that every engine reads, so an edit costs what it touches, every change can be undone, and a failed transaction leaves the document as it was.
Status: 0.3. The API may change between minor versions. Documentation: https://pyropdf.haya.works/. DESIGN.md describes the foundation, and CHANGELOG.md what each release holds.
pip install pyropdfimport pyropdf
with pyropdf.open("input.pdf") as doc:
page = doc.pages[0]
print(page.text())
page.pixmap(dpi=144).save("page-1.png")
with doc.transaction("rotate"):
page.rotation = 90
doc.save("output.pdf", incremental=True)0.3.0 reads text, words, layout, tables, images, fonts, and Markdown,
exports them as JSON or retrieval chunks, runs offline OCR, and renders
pages to pixmaps and SVG, drawing the CJK fonts that a document does not
embed in fallback faces. It draws paths and text in colors or gradients,
images, and pages, the text in Standard 14 or OpenType fonts, in color
glyphs and any weight of a variable face, with page.draw; edits pages and their boxes,
text, images, colors, annotations, links, form fields, outlines,
attachments, metadata, page labels, and layers; signs documents and verifies
signatures; removes hidden or active content and subsets fonts; and saves
incrementally, in full, or linearized, with encryption.
No pyropdf release claims safety for untrusted input before hayro's bounded
construction (I2, #15) is
released. DocumentLimits bounds the work of an operation, but it is not
that claim.
CONTRIBUTING.md explains how to build, test, and propose a change, and SECURITY.md how to report a vulnerability.