Compare
pdfboss vs pypdf.
pypdf, the continuation of PyPDF2, is the pure-Python library for working on documents as documents: splitting, merging, cropping, transforming, encrypting. pdfboss is a Rust engine for reading what is on the pages (text, Markdown, images, rendered pixels, forms and bookmarks) that also merges, splits, rotates and encrypts. Both are permissively licensed.
| pdfboss | pypdf | |
|---|---|---|
| License | MIT OR Apache-2.0 | BSD-3-Clause |
| Engine | Written from scratch in safe Rust; no C dependencies | Pure Python; optional extras for AES and images |
| Text extraction | Layout analysis (columns, reading order, word spacing); 10,312 pages/s over 40 PDFs | extract_text() per page, in pure Python |
| Rendering to PNG, PPM, BMP or JPEG | 161.9 pages/s (38 certified files, 888 pages) | Not provided |
| PDF to Markdown | pdfboss md, from layout | Not provided |
| Splitting and merging | merge, split, rotate, overlay, metadata; incremental updates or a full rewrite | Splitting, merging, cropping, transforming |
| Encrypted PDFs | Opens RC4 and AES-128/256 files; encrypts with AES-256 and decrypts | Decrypts and encrypts documents |
| Embedded images | extract_images() at native size, alpha applied | Image extraction with the Pillow extra |
| Async and remote | AsyncDocument over files and HTTP range requests | Synchronous API |
| Install | abi3 wheels for CPython 3.12+ | Pure Python, Python 3.9+, no compiled extension |
pdfboss throughput rows come from the pdfboss benchmark harness. The pdfboss README publishes no pypdf figure, so this page states no number for it. License and dependency statements come from each project’s PyPI metadata.
Migration
The reading path, side by side.
Both index pages 0-based. pdfboss’s extract_text() on the document covers all pages with layout analysis applied and spreads them across cores, and extract_markdown() adds headings, lists and tables detected from the page geometry.
from pypdf import PdfReader
reader = PdfReader("report.pdf")
print(len(reader.pages), "pages")
text = "\n".join(page.extract_text() for page in reader.pages)
first = reader.pages[0].extract_text()import pdfboss
doc = pdfboss.Document("report.pdf")
print(doc.page_count, "pages")
text = doc.extract_text()
markdown = doc.extract_markdown()
first = doc[0].extract_text()Where pypdf is ahead
What pypdf does that pdfboss does not.
- Cropping and transforming pages, filling form fields, and creating annotations. pdfboss merges, splits, rotates, overlays and re-encrypts, but does not crop, fill or annotate.
- Pure-Python portability: no compiled extension, so it installs anywhere Python 3.9 or later runs.
- History: pypdf continues PyPDF2, and a large body of existing code, answers and documentation targets its API.
Where pdfboss is ahead
What pdfboss does that pypdf does not.
- A compiled-Rust extractor with layout analysis that spreads pages across cores: 10,312 pages per second over the 40-file corpus.
- Rendering: pages rasterize to PNG, PPM, BMP or JPEG through an anti-aliased rasterizer with its own JPEG 2000, JBIG2, CCITT and ICC decoders.
- Markdown output with headings, lists and tables, and styled spans carrying font, weight, decorations and color.
- Embedded images at native size with alpha applied, with no extras to install.
- Async reading over HTTP range requests, and a per-page report of everything dropped or approximated.
- A jq-style query language and a terminal explorer over the document's element tree (pdfboss q, hex, json, tui).
Questions
- Is pdfboss a drop-in replacement for pypdf?
- Not as a drop-in: the APIs differ. pdfboss covers the reading side (text, Markdown, rendering, image extraction, forms and bookmarks) and document assembly (merge, split, rotate, encrypt, decrypt, watermark), each migrating in a few lines per call site. It does not crop or transform pages, fill forms or write annotations. The two coexist fine in one project.
- Is pdfboss faster than pypdf at extracting text?
- The pdfboss README publishes no pypdf figure, so no ratio is claimed here. pdfboss measures 10,312 pages per second over its 40-file corpus, from compiled Rust that runs layout analysis and spreads pages across cores; pypdf extracts in pure Python through a per-page extract_text() call, which is CPU-bound in the interpreter.
- Can pypdf render a PDF page to an image?
- No. pypdf works on documents as documents: splitting, merging, cropping, transforming, encrypting and decrypting, plus text and image extraction. It does not rasterize pages. pdfboss renders to PNG, PPM, BMP or JPEG at 161.9 pages per second over 888 certified pages on the measured corpus.
- Do the licenses differ in practice?
- Barely. pypdf is BSD-3-Clause and pdfboss is MIT OR Apache-2.0, all permissive licenses with attribution requirements and no copyleft. Both ship in commercial and closed-source software without a license to buy, so the choice is technical.