A standalone, general-purpose native Rust PDF layout and generation engine.
oxipdf consumes a structured layout tree (StyledTree IR) and emits paginated PDF output without browser or LaTeX runtime dependencies.
The core pipeline: IR ingestion, text shaping, spatial layout, fragmentation/pagination, reference resolution, and PDF emission.
- Pure Rust — no browser, LaTeX, or external runtime required
- Deterministic output — same input + same fonts = byte-identical PDF
- HarfBuzz-class text shaping via rustybuzz with OpenType feature support
- Block, flex, and grid layout via taffy
- Pagination with widow/orphan control, keep constraints, and cross-references
- Font subsetting — only used glyphs are embedded
- SVG support via usvg + svg2pdf
- Themeable — built-in and custom TOML themes for semantic role styling
- HTML adapter — optional
oxipdf-htmlcrate for HTML+CSS input
use oxipdf::ir::*;
let mut builder = StyledTreeBuilder::new(IrVersion::new(1, 0));
let root = builder.add_node(
ContentVariant::Container,
ResolvedStyle::default(),
None,
None,
);
let _text = builder.add_child(
root,
ContentVariant::Text(TextContent::new("Hello, oxipdf!")),
ResolvedStyle::default(),
None,
None,
);
let tree = builder.build().expect("valid tree");StyledTree IR ─► Text Shaping ─► Spatial Layout ─► Fragmentation ─► PDF Emission
(oxipdf-ir) (oxipdf-shaping) (oxipdf-layout) (oxipdf-fragment) (oxipdf-emit)
Each pipeline stage is a separate crate with a clear contract. Data flows one direction — cross-crate dependency cycles are forbidden.
| Crate | Purpose |
|---|---|
oxipdf-ir |
IR types, StyledTree, styles, units |
oxipdf-shaping |
Text shaping, font provider, line breaking |
oxipdf-layout |
Spatial layout via taffy |
oxipdf-fragment |
Pagination, fragmentation, cross-references |
oxipdf-emit |
PDF object emission, font subsetting |
oxipdf-theme |
Semantic role to resolved style mapping |
oxipdf-html |
HTML+CSS to StyledTree adapter |
[dependencies]
oxipdf = "0.1"| Flag | Default | Description |
|---|---|---|
std |
Yes | Full engine (required) |
parallel |
Yes | Rayon-based parallelism (disable for WASM) |
hyphenation |
No | Knuth-Liang dictionary hyphenation |
Rust 1.85 or later.
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.