forme-pdf
A page-native PDF rendering engine written in Rust. Layout happens into pages, not onto an infinite canvas that gets sliced afterward — so page breaks, table headers, and flex layout all work correctly across pages.
cargo add forme-pdf installs the crate. The library name is forme:
use ;
Features
- Page-native layout — flexbox, tables, and text reflow with real page boundary awareness
- CSS-like styling — flexbox (
row/column,wrap,grow/shrink), CSS Grid, absolute positioning - Text — OpenType shaping, Knuth-Plass line breaking, hyphenation (35+ languages), BiDi, per-character font fallback
- Tables — automatic header repetition on page breaks, column spans
- Images — JPEG, PNG, WebP (embedded or data URI)
- SVG — inline SVG rendering (rect, circle, line, path, arc)
- Charts — BarChart, LineChart, PieChart, AreaChart, DotPlot (engine-native, no JS)
- QR codes & barcodes — vector rendering (Code128, Code39, EAN13, EAN8, Codabar)
- Canvas — arbitrary vector drawing via a Canvas-like API
- Watermarks — rotated text behind page content
- Tagged PDF / PDF/A-2a — accessibility and archival compliance
- Templates — expression language for dynamic documents (
$ref,$each,$if) - WASM — compiles to WebAssembly for browser and serverless use
Quick start
use ;
API
| Function | Description |
|---|---|
render(&Document) |
Render a document struct to PDF bytes |
render_json(&str) |
Parse JSON and render to PDF bytes |
render_with_layout(&Document) |
Render and return layout metadata |
render_template(&str, &str) |
Evaluate a template with data, then render |
All functions return Result<Vec<u8>, FormeError> (or a tuple with LayoutInfo for the _with_layout variants).
Documentation
- Full docs — component reference, styling guide, examples
- API reference — Rust API docs
- GitHub — source, issues, JSX/TypeScript packages
License
MIT