Skip to main content

Crate lightweight_pdf_layout

Crate lightweight_pdf_layout 

Source
Expand description

Layoutable trait, pagination and text wrapping for lightweight-pdf. Knows lightweight-pdf-core’s element types, but nothing about lightweight-pdf-writer or fonts beyond the FontResolver contract (ADR-010).

Structs§

Constraints
LayoutCtx
LayoutWarning
PageRender
PaginatedDocument
Rect
Coordinates are page-relative, top-down (x grows right, y grows down from the top of the body/header/footer band) — a purely internal layout convention. The facade converts to PDF’s bottom-left origin only at the very end, when translating a RenderNode tree into content-stream ops.
RichLine
One wrapped line of a Text::rich(..) paragraph. height is size * line_height of the line’s tallest word (not a fixed, whole-paragraph value like plain Text’s line_height_pt); ascent_pt is that same tallest word’s ascent, in points — every word on the line shares this one baseline reference regardless of its own size, which is what keeps mixed sizes visually aligned on one baseline instead of each hanging from its own.
Size
StyledWord
One word plus the style it should be drawn in — the atomic unit wrap_spans arranges into RichLines.
TocHeading
One heading, discovered from the pre-layout Element tree by [prepare_toc] — everything a TableOfContents entry needs except the page number (added later, pass 2 only, via LayoutCtx::toc_heading_pages).

Enums§

LayoutResult
Result of laying an element out into a bounded area: either it fully fit, or the fitting part plus a materialized remainder element for the next page. Text, Column and Table produce Split in V1.
LayoutWarningKind
RenderNode
Positioned, resolved layout output ready for the facade to translate into lightweight-pdf-writer content-stream operations. Never seen by lightweight-pdf-writer directly (plan/00a-contracts-and-artifacts.md point 3).
StructRole
The PDF standard structure types (ISO 32000-1 14.8.4, Table 333/334) this crate tags content with — no RoleMap needed since all of these are standard types. Grouping roles (see StructRole::is_grouping) nest child StructElems and own no marked content of their own; Artifact is excluded from the structure tree entirely (watermarks, running headers/footers — PDF/UA pagination artifacts, not content).

Traits§

FontMetrics
Per-font metrics, normalized to 1000 units-per-em (PDF/Type1 convention). lightweight-pdf-layout never sees font bytes — only this.
FontResolver
lightweight-pdf-layout’s only dependency on fonts: given a FontKey, hand back metrics. Implemented by the facade crate, which bridges to lightweight-pdf-fonts::FontData (ADR-010).
Layoutable

Functions§

align_offset
Just used inside Row/Column cross-axis alignment.
paginate
paginate_body
Repeatedly lays the document body out into an identical, fixed-size box per page until every child has been placed. Returns one RenderNode per page.
text_width_pt
wrap_text
Wraps text to max_width points. Explicit \n in the source text start a new paragraph/line unconditionally.