Skip to content

Fullbleed 2.5.25: author PDFs with Python components

Choose a tag to compare

@krflol krflol released this 15 Oct 17:58
· 211 commits to master since this release
e4de73a

Fullbleed 2.5.25 makes Python components a complete document-authoring workflow. Compose named components with ordinary functions, keyword props, children, loops and conditions; attach styles and render a PDF or PNG with an explicit engine. The complete invoice example uses Python style mappings and no authored HTML.

from fullbleed.ui import Document, Heading, Paragraph, Stack, StyleSheet, component

@component
def Line(label: str, amount: str):
    return Paragraph(label, ": ", amount)

@Document(styles=StyleSheet({"@page": {"size": "A4", "margin": "18mm"}}))
def Invoice(customer: str, items: list[dict]):
    return Stack(
        Heading("Invoice for ", customer, level=1),
        [Line(item["label"], item["amount"]) for item in items],
        gap="12pt",
    )

The complete guide includes explicit fonts, rendering and exports. Download the runnable invoice project, PDF, or inspect its preview:

Invoice composed from Python functions and style mappings.

StyleSheet composes shared rules and overrides. Stack, Row and LayoutGrid accept layout props and have small overridable defaults. Named text, structure, image and table components support rich children. Nested lists and generators are snapshotted once; booleans omit conditional children, while zero remains visible. Escaping, ARIA/data booleans, decorated signatures, cycles, invalid names, void elements, nested documents and CSS declaration boundaries are hardened.

Compatibility: collection/generator representations and boolean placeholders no longer print as text; format them explicitly when intended. Invalid input now fails clearly. Existing explicit HTML/CSS rendering retains its styling. The model is inspired by React composition and evaluates to static print documents; no browser or React runtime is added.

Validation: all 655 Python tests and 105 focused authoring checks pass without skips. All 15 applicable CI jobs pass, covering Windows/Linux and Python compatibility. Seven component documents produce 15 PDF pages; local, Windows CI, Linux CI and the fresh PyPI installation reproduce identical PDF and native preview bytes. Checks include text, glyphs, row uniqueness, layout geometry and deterministic rendering. A fresh default-feature crates.io consumer renders the six invoice variants from exported HTML/CSS identically. The unchanged Rust engine is released with synchronized metadata; this does not add Rust components.

Other language component APIs remain separate follow-up work. These checks do not establish PDF standards conformance; the unavailable dedicated PDF/VT validator remains skipped. Source and review: #81.