Semantic DSL
Describe modules, sections, paragraphs, tables, layers, and themes instead of manual PDF coordinates.
GraphCompose
Java-first declarative document layout engine for cinematic PDFs.
Describe documents semantically. GraphCompose handles layout, pagination, snapshots, and PDFBox rendering.
What it is
GraphCompose is a Java document layout engine that lets you describe document structure using semantic building blocks such as modules, sections, paragraphs, tables, layers, and themes.
Instead of manually calculating x/y coordinates, you define what the document means. GraphCompose compiles that structure into a deterministic layout and renders the final output through PDFBox.
Showcase gallery
Each card is loaded from examples.json. Add a screenshot, add a PDF, then add one JSON object.
Architecture
GraphCompose is responsible for document structure, layout, pagination, and snapshots. PDFBox is the rendering backend that draws the resolved fixed layout.
The DSL describes semantic structure. The layout engine resolves geometry, pagination, and visual rules. The rendering backend then draws the final fixed layout using PDFBox.
Highlights
Describe modules, sections, paragraphs, tables, layers, and themes instead of manual PDF coordinates.
Let the engine split long flows, tables, and document sections across pages with deterministic placement.
Compose invoices, proposals, CVs, cover letters, and operational documents from typed data specs.
Inspect resolved layout before PDF bytes are written and keep visual regressions testable.
Render through an isolated PDFBox backend while keeping authoring and layout rules engine-owned.
Use theme tokens, layered panels, transforms, accents, and visual hierarchy without low-level drawing code.
Build business tables with row spans, zebra rows, totals, and repeated headers.
Place content inside clipped or rounded visual containers while preserving layout behavior.
Write generated PDFs to caller-owned streams for HTTP responses, storage uploads, and backend workflows.
Install
Check the GitHub repository for the latest release version.
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.DemchaAV</groupId>
<artifactId>GraphCompose</artifactId>
<version>v1.5.1</version>
</dependency>
Minimal idea
try (DocumentSession document = GraphCompose.document(Path.of("invoice.pdf"))
.pageSize(DocumentPageSize.A4)
.margin(48)
.create()) {
document.pageFlow(page -> page
.addSection("Summary", section -> section
.addParagraph(p -> p.text("Invoice ready for review"))));
document.buildPdf();
}