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 and rendered pixels. Both are permissively licensed, and they overlap far less than their names suggest.
| 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 | Not supported | Core strength: splitting, merging, cropping, transforming |
| Encrypted PDFs | Opens RC4 and AES-128/256 files with a password | Decrypts and also 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.
- Document manipulation: splitting, merging, cropping and transforming pages, plus reading and creating annotations. pdfboss does not edit existing files beyond watermarking, which appends an incremental update.
- Encryption on write as well as read: pypdf decrypts and encrypts documents; pdfboss only opens encrypted files.
- 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?
- No, and for much of pypdf's surface it is no replacement at all: pdfboss does not split, merge, crop or transform existing documents. It replaces the reading side, where text, Markdown, rendering and image extraction migrate in a few lines per call site. 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 document structure: 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.