Rust
PDF parsing and rendering in pure Rust.
pdfboss is a workspace of focused crates sharing one version: a clean-room parser built from ISO 32000, layout analysis to text and Markdown, an anti-aliased rasterizer, in-tree JPEG 2000, JBIG2, CCITT and ICC codecs, async range-fetching I/O and a deterministic PDF writer. Safe Rust, no C dependencies, no bindings to another engine.
Install
Add only what you use.
pdfboss-core alone parses; the others build on it. Optional features stay off by default in the library crates: substitute-fonts on pdfboss-render bundles replacement faces for PDFs that do not embed theirs, predefined-cmaps on pdfboss-core compiles in the CJK CMap set, and http on pdfboss-aio enables remote documents over HTTP range requests.
$ cargo add pdfboss-core pdfboss-output pdfboss-render
# optional: pdfboss-text pdfboss-write pdfboss-markdown pdfboss-aio
$ cargo add pdfboss-aio --features httpQuickstart
Open, extract, rasterize.
render_page returns an RGBA Pixmap; save_png and encode_png turn it into a file or bytes. render_page_reporting returns the same pixels plus every dropped or approximated item. Page indexes are 0-based.
use pdfboss_core::Document;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let doc = Document::open("report.pdf")?;
println!("{} pages", doc.page_count());
let page = doc.page(0)?;
let text = pdfboss_output::extract_text(&doc, &page)?;
println!("{text}");
let pixmap = pdfboss_render::render_page(&doc, &page, 2.0)?;
pixmap.save_png("page.png")?;
Ok(())
}The workspace
Thirteen crates on crates.io, one implementation.
No borrowed decoders and no C. Each crate’s API reference lives on docs.rs; the Rust reference chapter says where to start for reading, extracting, rasterizing, creating, composing Markdown, async sources and element iteration.
pdfboss-core
The clean-room PDF parser, built from ISO 32000.
pdfboss-text
Fonts, encodings and text extraction.
pdfboss-output
Layout analysis to plain text and Markdown.
pdfboss-render
The anti-aliased rasterizer: pages to PNG, PPM, BMP or JPEG.
pdfboss-write
PDF creation: canvas, elements, COS writer.
pdfboss-markdown
CommonMark+GFM composed into PDFs.
pdfboss-style
CSS-subset themes for composition.
pdfboss-aio
Async, range-fetching I/O over files and HTTP.
pdfboss-jpx
JPEG 2000 decoding, ITU-T T.800.
pdfboss-icc
ICC color profiles.
pdfboss-encoding
Font encoding tables and glyph names.
pdfboss-cli
The command line.
pdfboss-tui
The terminal explorer.
pdfboss-py
PyO3 bindings, shipped as the pdfboss wheel.
Design
What the crates promise.
- Lenient reading: broken cross-reference tables are reconstructed, wrong stream lengths tolerated, garbage operators skipped, and every dropped or approximated item is reported.
- Lazy page trees: opening a document reads its declared page count instead of parsing every page dictionary up front.
- Deterministic output from pdfboss-write: the same composition always serializes to the same bytes.
- Clean-room codecs implemented from their specifications: ITU-T T.800 for JPEG 2000, T.88 for JBIG2, T.4 and T.6 for CCITT, ICC.1:2010 for color.