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
| Page | Covers |
|---|---|
| Charts | Native 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 pagination | keepTogether() / keepEntriesTogether() — blocks that relocate whole instead of orphaning a heading at a page break |
| Themes | BusinessTheme.classic / modern / executive, page background, palette slots, text scale, the CvTheme ↔ BusinessTheme bridge |
| Shapes and visual primitives | Filled cards, dividers, spacers, lines, ellipses, image fit modes, soft panels |
| Shape-as-container | addCircle / addEllipse / addContainer with ClipPolicy (clipped layered children) |
| Transforms and z-index | rotate / scale mixin, per-layer zIndex for overlays |
| Page backgrounds | pageBackground / pageBackgrounds, PageBackgroundFill columns, bands, point-based fills, layering |
| Layered page design | Choosing between page backgrounds, rows, layer stacks, and canvases |
| Absolute placement | addCanvas + position(x, y) for pixel-precise certificates and badges |
| Tables | Row span, zebra rows, totals row, repeated header on page break |
| Rich text | RichText mixed-style runs, inline links/images/shapes, checkboxes |
| Lists | addList, marker customisation, nested lists with per-depth markers |
| Timelines | addTimeline: markers on a connector rail, geometry and text-style controls |
| Barcodes | QR / Code 128 / EAN / UPC and friends, tinting, quiet zone |
| Images | Sources, sizing precedence, fit modes, images in rows and cards |
| PDF chrome | Metadata, watermarks, running header/footer placeholders, protection, links, bookmarks |
| Translucency | DocumentColor.rgba / withOpacity, alpha coverage, layered tints |
| DOCX export | Semantic export, node mapping, fallbacks and skipped kinds |
| Snapshot testing | Layout-snapshot regression testing in consumer projects |
| Streaming and output | buildPdf / writePdf / toPdfBytes, DOCX export, layout snapshots, header / footer chrome, guide lines |
| Extending GraphCompose | New semantic node, fluent setter, render backend, snapshot-based regression tests |
For longer-form material:
- Extension guide — walkthrough of the four
extension paths with the v1.5
ShapeContainerNodework as a worked example. - Migration v1.4 → v1.5 — every public API change in v1.5 plus suggested migration order.
- Font coverage and glyph fallback — WinAnsi limits,
●vs•, and the inline-shape / bundled-font alternatives. ADR 0001 — Shape as containerandADR 0002 — Theme unificationfor the design reasoning behind the two largest v1.5 additions.
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.