Java · v2.1.1 · MIT

Java PDF layout engine for structured business documents.

Describe documents. Render polished PDFs. A semantic layout engine for Java services that need structured, paginated, theme-driven output — CVs, invoices, proposals, reports.

No drawing API. No pixel arithmetic. You compose ParagraphNode, TableNode, SectionNode; GraphCompose handles measurement, pagination, fonts, and PDFBox rendering.

The same resolved layout also renders to an editable PowerPoint deck — one page per slide, geometry-identical to the PDF, text and panels as native shapes. Opt in with graph-compose-render-pptx (@Beta).

Cinematic project proposal preview Cinematic invoice preview Blue Banner CV preview
NEW

Building your own templates?

The layered architecture guide walks you through the five-folder pattern — data / theme / components / widgets / presets — with a worked CV example, widget cookbook, and step-by-step contributor checklist. New templates and major rewrites follow this shape.

30 lines → one invoice

The whole stack — theme tokens, table, totals, chrome — behind one fluent DSL.

Atomic pagination

Tables split row-by-row, rows are atomic, layer stacks atomic. No manual page math.

16 CV presets, 15 matching letters

Every preset is one final class with a one-liner create(BrandTheme) factory.

Tested at every layer

A full-reactor verify gate on every push: layout snapshots per preset, pixel-diff visual parity, public-API leak guards.

Maven Central. One dependency.

Maven

<dependency>
  <groupId>io.github.demchaav</groupId>
  <artifactId>graph-compose</artifactId>
  <version>2.1.1</version>
</dependency>

Gradle

dependencies {
  implementation(
    'io.github.demchaav:graph-compose:2.1.1'
  )
}

30-second hello world

try (var doc = GraphCompose
        .document(out).create()) {
  doc.pageFlow()
     .addParagraph("Hello, GraphCompose")
     .addList(l -> l.items(
         "PDF", "DOCX", "Tables"))
     .build();
  doc.buildPdf();
}

Generated PDFs you can inspect.

Every example below is a real, runnable Java file. Click the preview to open the rendered PDF, or jump straight into the source.

Loading examples...

Author intent stays separate from PDF rendering.

  1. Semantic DSL. You build a tree of ParagraphNode, TableNode, SectionNode, LayerStackNode, CanvasLayerNode.
  2. Layout pass. The engine resolves measurements, pagination, decoration, overlays. Output is a LayoutGraph — geometry only, no draw calls.
  3. Render backend. The FixedLayoutBackend consumes placed fragments. Default: PdfFixedLayoutBackend via PDFBox. PptxFixedLayoutBackend consumes the same fragments, so a deck is geometry-identical to the PDF by construction. A semantic DOCX backend maps the node tree instead, with much narrower coverage.

For services that produce structured PDFs at scale.

Stream straight into HTTP responses

session.writePdf(OutputStream) writes incrementally with no in-memory buffering. Spring Boot, Quarkus, Micronaut, or plain Java HTTP.

Snapshot-tested layouts

Every preset has a layout-graph JSON baseline plus a pixel-diff visual parity baseline. Regressions surface on the first run.

Theme tokens, not magic numbers

BrandTheme.modernProfessional() / .executive() / .boxedClassic() set palette, typography, table styles. Override one or all. Ships in graph-compose-templates.

Markdown-aware bodies

Inline **bold**, *italic*, _italic_ markers parsed in every paragraph and list block automatically.