Expand description
Document model, elements and builder API for lightweight-pdf. No font bytes, no
PDF types (plan/00a-contracts-and-artifacts.md, point 3) — this crate
knows nothing but the document tree, styling and FontKey.
Structs§
- Border
- Color
- Column
- Common
- Properties shared by every container/block element:
padding, width, height, overflow, background, border, plusflex(taffy-vocabulary, ADR-004) andkeep_with_next(ADR-007 / Grundprinzip 9). Deliberately nomarginon elements (ADR/03: onlypadding+Row/Columngap, margin is aDocument-level property). - Document
- Document
Metadata - FontKey
- Opaque handle for a font.
lightweight-pdf-corenever sees font bytes, only this key (seeplan/00a-contracts-and-artifacts.md, point 3). - Footer
- Header
- A header band with a fixed, document-creation-time height (ADR-011): the closure may vary its content per page but never the reserved band size.
- Image
- A validated, embeddable JPEG or PNG.
bytesare the original file bytes, kept as-is — pixel decoding (only ever needed for PNG, to split out the alpha channel as aSMask) happens later, in the facade. - Line
- List
- List
Item - Margin
- Page
Context - Passed to
Header/Footerclosures on every (re-)evaluation. Plain data only, so it can live inlightweight-pdf-corewithout pulling in layout/font knowledge (ADR-010). - PdfDate
- A UTC timestamp for
/CreationDate//ModDate. Always an explicit caller-supplied value, never read from the system clock:wasm32-unknown-unknownhas none, and reproducible output (sameDocument-> byte-identical PDF) is a feature, not an accident. - Rect
- Row
- Spacer
- Span
- One independently-styled run within
Text::rich(..). - Table
- Table
Cell - Table
Column - Table
OfContents - Self-populating from every
Text::outline_level/.heading1()-etc. heading in the document (the same source the PDF bookmark sidebar is built from), with correct page numbers — the two-pass layout already determines those in pass 1, this element just renders them in pass 2 (seelightweight-pdf-layout::toc). Entries are always left-aligned, one per line, indented by heading depth, with a leader (.leader()) filling the gap to a right-hand page number;.stylecontrols font/size/color for every entry uniformly. - Text
- Text
Style - Theme
- Named
TextStyleroles.Theme::default()reproduces exactly the hardcoded valuesTextStyle::default()/.heading1()/.heading2()/.heading3()already used beforeThemeexisted (caption/table_header/mutedare new roles with no prior hardcoded equivalent, so they can’t break existing output either way). - Watermark
Enums§
- Align
- Border
Style - Column
Width - A column’s width:
fixed(w)reserves an exact width,flex(weight)shares the leftover space proportionally (taffyflex-growanalogy, ADR-004 /03-builder-api-design.md) — the same distribution step asRow, not a generic flex implementation. - Element
- One element in the document tree. Enum-based (not
Box<dyn Layoutable>) — a closed, small set of primitives. - Hyphenation
Language - A language
.hyphenate(lang)can insert Knuth-Liang break points for (lightweight-pdf-layout’shyphenationfeature; see that crate’shyphenatemodule for the dictionaries themselves). - Image
Error - Image
Format - Marker
- Orientation
- Overflow
- Overflow policy for explicitly, fixed-size elements. See
plan/05-overflow-and-robustness.md, Grundprinzip 3.Visibleis intentionally not part of V1 (ADR-011). - Page
Format - Page formats supported for documents. Dimensions in PDF points (1/72 inch).
- Theme
Role
Traits§
- Table
Row - Implemented by a domain type (an invoice line item, a report row, …)
that knows how to render itself as one table row — lets callers write
Table::new()...from_rows(&items)instead of hand-buildingvec![vec![Element::from(..), ...]]per row, where the column order is invisible at the call site and only checked at runtime. The plain.rows(vec![vec![..]])form stays available for ad hoc tables.
Functions§
- format_
currency_ de - Formats a cent amount as German currency: thousands-grouped with
., decimal comma, trailing€— e.g.format_currency_de(123456) == "1.234,56 €".