Skip to main content

Crate forme

Crate forme 

Source
Expand description

§Forme

A page-native PDF rendering engine.

Most PDF renderers treat a document as an infinite vertical canvas and then slice it into pages after layout. This produces broken tables, orphaned headers, collapsed flex layouts on page boundaries, and years of GitHub issues begging for fixes.

Forme does the opposite: the page is the fundamental unit of layout. Every layout decision—every flex calculation, every line break, every table row placement—is made with the page boundary as a hard constraint. Content doesn’t get “sliced” after the fact. It flows into pages.

§Architecture

Input (JSON/API)
      ↓
  [model]    — Document tree: nodes, styles, content
      ↓
  [style]    — Resolve cascade, inheritance, defaults
      ↓
  [layout]   — Page-aware layout engine
      ↓
  [pdf]      — Serialize to PDF bytes

Re-exports§

pub use error::FormeError;
pub use layout::LayoutInfo;
pub use model::CertificationConfig;
pub use model::ColumnDef;
pub use model::ColumnWidth;
pub use model::FontEntry;
pub use model::PatternType;
pub use model::RedactionPattern;
pub use model::RedactionRegion;
pub use model::TextRun;
pub use model::ChartDataPoint;
pub use model::ChartSeries;
pub use model::DotPlotGroup;
pub use model::Document;
pub use model::Metadata;
pub use model::Node;
pub use model::NodeKind;
pub use model::PageConfig;
pub use model::PageSize;
pub use style::Style;

Modules§

barcode
1D Barcode Generation
chart
Chart Rendering
error
Structured error types for the Forme rendering engine.
font
Font Management
image_loader
Image Loading and Decoding
layout
Page-Aware Layout Engine
model
Document Model
pdf
PDF Serializer
qrcode
QR Code Generation
style
Style System
svg
SVG Parser
template
Template expression evaluator.
text
Text Layout

Structs§

RenderOptions
Opt-in per-render checks. Default disables everything, and every disabled check costs nothing — the flag is tested once per render. Deserializes from the camelCase JSON the JS wrappers send ({"auditContent": true}), unknown fields ignored so older engines tolerate newer wrappers.

Functions§

certify_pdf
Certify PDF bytes with an X.509 certificate.
count_layout_passes
Number of full layout passes a document needs (1 for the common case; 2–3 only when a page-number sentinel’s reserved width must be corrected). Exposed as the regression guard for the sentinel re-layout optimization.
find_text_regions
Find text regions matching patterns in a PDF.
merge_pdfs
Merge multiple PDFs into a single document.
redact_pdf
Redact regions of a PDF by overlaying opaque rectangles.
redact_text
Redact text matching patterns from a PDF.
render
Render a document to PDF bytes.
render_json
Render a document described as JSON to PDF bytes.
render_json_with_layout
Render a document described as JSON to PDF bytes along with layout metadata.
render_json_with_layout_and_options
Like render_json_with_layout, with opt-in RenderOptions — the JSON-input mirror of render_with_layout_and_options, used by the WASM bindings so @formepdf/core callers can opt into the content audit the way the HTML path already can.
render_template
Render a template with data to PDF bytes.
render_template_with_layout
Render a template with data to PDF bytes along with layout metadata and the render’s warnings.
render_with_layout
Render a document to PDF bytes along with layout metadata.
render_with_layout_and_options
Like render_with_layout_and_passes, with opt-in RenderOptions.
render_with_layout_and_passes
Like render_with_layout, but also returns the number of layout passes the render took (1 for the common case; 2-3 when a page-number sentinel’s reserved width needed correction). The plain variant discarded this value, which is how renderHtmlWithLayout shipped without passes on every target while its declared type promised one.
render_with_options
render_with_warnings
Render a document to PDF bytes plus any non-fatal warnings (e.g. pdfUa requested without an embeddable font registered). Same output as render; the warnings surface through the WASM bindings and the HTML wrapper.
render_with_warnings_and_passes
Like render_with_warnings, but also returns the number of layout passes the render took — surfaced through the HTML wrapper for benchmark evidence.