Compare
pdfboss vs pypdfium2.
pypdfium2 binds PDFium, the C++ engine inside Chrome, under permissive licenses. pdfboss is a PDF engine written from scratch in Rust with no C or C++ in it. Both are free for commercial use, so the differences are speed, the output surface, and how much you can see when something goes wrong.
| pdfboss | pypdfium2 | |
|---|---|---|
| License | MIT OR Apache-2.0 | BSD-3-Clause and Apache-2.0; PDFium is BSD-3-Clause |
| Engine | Written from scratch in safe Rust | ctypes bindings to PDFium, written in C++ |
| Rendering to PNG, PPM, BMP or JPEG | 161.9 pages/s | 120.1 pages/s (38 certified files, 888 pages) |
| Scanned JBIG2 book | 65.2 pages/s | 52.9 pages/s (544 pages at 1:1) |
| Text extraction | Layout analysis to plain text; 10,312 pages/s over 40 PDFs | Character-level text page; layout left to the caller |
| PDF to Markdown | pdfboss md, from layout | Not provided |
| Async and remote | AsyncDocument over files and HTTP range requests | Synchronous API |
| Creating PDFs | Composable write API, Markdown to PDF with CSS themes | Basic creation through the raw PDFium API |
| Reporting | Every dropped or approximated item is reported per page | No per-page report of skipped content |
| Wheels | abi3 wheels for CPython 3.12+, no native dependency | Wheels bundling the PDFium binary |
Throughput rows come from the pdfboss benchmark harness, where pypdfium2 was measured in the same session as pdfboss.
Migration
Rendering and text, side by side.
pdfboss returns PNG, PPM, BMP or JPEG bytes from render directly, so there is no bitmap object to convert. Text comes back with layout analysis already applied, and Markdown is one more call.
before.py · pypdfium2
import pypdfium2 as pdfium
pdf = pdfium.PdfDocument("report.pdf")
page = pdf[0]
text = page.get_textpage().get_text_range()
bitmap = page.render(scale=2)
bitmap.to_pil().save("page.png")after.py · pdfboss
import pdfboss
doc = pdfboss.Document("report.pdf")
page = doc[0]
text = page.extract_text()
markdown = page.extract_markdown()
open("page.png", "wb").write(page.render(scale=2.0))Where pypdfium2 is ahead
What pypdfium2 does that pdfboss does not.
- PDFium's rendering coverage: two decades of shadings, transparency and edge cases from the engine that renders PDFs in Chrome.
- Form-field rendering and the rest of the raw PDFium API for callers who need it.
- Maturity: a long history of production use behind the binding.
Where pdfboss is ahead
What pdfboss does that pypdfium2 does not.
- Faster rendering on the measured corpus, and no C or C++ in the wheel.
- Layout analysis to plain text and Markdown, with styled spans carrying font, weight, decorations and color.
- Async reading over HTTP range requests.
- A report of everything dropped or approximated on a page, so a fast render is never a silent one.
- A composable PDF writer, Markdown to PDF, and a jq-style explorer over the document's element tree.
Questions
- Are pdfboss and pypdfium2 both free for commercial use?
- Yes. pypdfium2 is released under BSD-3-Clause and Apache-2.0 and wraps PDFium, which is BSD-3-Clause. pdfboss is MIT OR Apache-2.0. Neither carries copyleft obligations.
- Which one renders faster?
- On the measured corpus pdfboss rasterizes 161.9 pages per second against pypdfium2's 120.1 over 888 certified pages, about 35% faster, and 65.2 against 52.9 on a 544-page JBIG2 scan, about 23% faster. Numbers are machine-dependent; the harness in the pdfboss repository reproduces them.
- Does pypdfium2 extract Markdown?
- No. PDFium exposes a text page with character positions and bounding boxes; layout, reading order and structure are left to the caller. pdfboss ships layout analysis to plain text and Markdown, with headings, lists and tables detected from the page geometry.
- When would you still pick pypdfium2?
- When you need PDFium's rendering coverage on unusual files today, form-field rendering, or parts of the PDFium API that pdfboss does not expose. pdfboss reports what it cannot yet paint instead of guessing, and on files where it reports drops, PDFium may paint more.