Recipes

June 10, 2026 · View on GitHub

GraphCompose recipes are split into focused pages so each page covers one topic end-to-end. All recipes use only the canonical session-first authoring API; public application code should not import com.demcha.compose.engine.*.

Topic-focused recipe pages

PageCovers
ChartsNative vector bar / line / area / pie-donut charts: data–spec–style layers, axis & grid toggles, point markers, value-label halos, legend placement, translucent area fills
Keep-together paginationkeepTogether() / keepEntriesTogether() — blocks that relocate whole instead of orphaning a heading at a page break
ThemesBusinessTheme.classic / modern / executive, page background, palette slots, text scale, the CvThemeBusinessTheme bridge
Shapes and visual primitivesFilled cards, dividers, spacers, lines, ellipses, image fit modes, soft panels
Shape-as-containeraddCircle / addEllipse / addContainer with ClipPolicy (clipped layered children)
Transforms and z-indexrotate / scale mixin, per-layer zIndex for overlays
Page backgroundspageBackground / pageBackgrounds, PageBackgroundFill columns, bands, point-based fills, layering
Layered page designChoosing between page backgrounds, rows, layer stacks, and canvases
Absolute placementaddCanvas + position(x, y) for pixel-precise certificates and badges
TablesRow span, zebra rows, totals row, repeated header on page break
Rich textRichText mixed-style runs, inline links/images/shapes, checkboxes
ListsaddList, marker customisation, nested lists with per-depth markers
TimelinesaddTimeline: markers on a connector rail, geometry and text-style controls
BarcodesQR / Code 128 / EAN / UPC and friends, tinting, quiet zone
ImagesSources, sizing precedence, fit modes, images in rows and cards
PDF chromeMetadata, watermarks, running header/footer placeholders, protection, links, bookmarks
TranslucencyDocumentColor.rgba / withOpacity, alpha coverage, layered tints
DOCX exportSemantic export, node mapping, fallbacks and skipped kinds
Snapshot testingLayout-snapshot regression testing in consumer projects
Streaming and outputbuildPdf / writePdf / toPdfBytes, DOCX export, layout snapshots, header / footer chrome, guide lines
Extending GraphComposeNew semantic node, fluent setter, render backend, snapshot-based regression tests

For longer-form material:

Common DSL primitives — quick snippets

The following snippets cover the three smallest "I just want to put text on a page" patterns. Use them as starting points before reaching for a focused recipe page.

Paragraph module

document.pageFlow(page -> page
        .module("Professional Summary", module -> module.paragraph(
                "Backend engineer focused on secure Java systems and reliable document generation.")));

Bullet list

document.pageFlow(page -> page
        .module("Technical Skills", module -> module.bullets(
                "Java 21",
                "Spring Boot",
                "PostgreSQL",
                "Docker")));

Markerless rows

document.pageFlow(page -> page
        .module("Projects", module -> module.rows(
                "GraphCompose - Declarative PDF/document layout engine.",
                "CVRewriter - Profile-aware CV tailoring platform.")));

Snapshot regression in a test

import com.demcha.compose.testing.layout.LayoutSnapshotAssertions;

try (DocumentSession document = GraphCompose.document().create()) {
    document.pageFlow(page -> page
            .module("Snapshot Example", module -> module.paragraph("Hello GraphCompose")));

    LayoutSnapshotAssertions.assertMatches(document, "my-feature/hello");
}

See recipes/extending.md § 4 for the full snapshot workflow including baseline approval.