Installation
forme-pdf on crates.io. The library name is forme:
Quick start
API
PDF operations
All functions return
Result<Vec<u8>, FormeError> (or Result<(Vec<u8>, LayoutInfo), FormeError> for the _with_layout variants).
Working with the Document struct
For full control, build aDocument directly instead of using JSON:
Templates
Render dynamic documents by combining a template (with$ref, $each, $if expressions) and a data object:
Layout metadata
The_with_layout variants return a LayoutInfo struct describing the position and dimensions of every element on every page. Useful for overlays, click-to-inspect, and testing:
Features
The engine supports:- Flexbox layout — row, column, wrap, grow/shrink, all alignment modes
- CSS Grid — track sizing, auto/explicit placement,
repeat()syntax - Text — OpenType shaping, Knuth-Plass line breaking, hyphenation (35+ languages), BiDi, per-character font fallback
- Tables — automatic header repetition on page breaks
- Images — JPEG, PNG, WebP
- SVG — inline rendering (rect, circle, line, path, arc)
- Charts — BarChart, LineChart, PieChart, AreaChart, DotPlot
- QR codes & barcodes — Code128, Code39, EAN13, EAN8, Codabar
- AcroForms — fillable PDF forms (TextField, Checkbox, Dropdown, RadioButton) with form flattening
- Digital signatures — PKCS#7 detached signatures with X.509 certificates (PKCS#1 and PKCS#8 keys)
- PDF/UA-1 — accessibility compliance with structure tree and artifact tagging
- PDF/A — archival compliance (PDF/A-2b, PDF/A-2a)
- PDF operations — merge, certify, redact, and text search on existing PDFs
- Embedded data — attach JSON inside the PDF for round-tripping
WASM
The crate compiles to WebAssembly. Enable thewasm feature for wasm-bindgen support:
@formepdf/core works under the hood — the same engine, compiled to WASM and called from JavaScript.