GraphCompose

Java-first declarative document layout engine for cinematic PDFs.

Describe documents semantically. GraphCompose handles layout, pagination, snapshots, and PDFBox rendering.

Generated invoice PDF preview Generated proposal PDF preview Generated CV PDF preview

Semantic document authoring for Java services.

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.

Generated PDFs you can inspect.

Each card is loaded from examples.json. Add a screenshot, add a PDF, then add one JSON object.

Author intent stays separate from fixed PDF rendering.

GraphCompose is responsible for document structure, layout, pagination, and snapshots. PDFBox is the rendering backend that draws the resolved fixed layout.

  1. Semantic DSL
  2. Layout Graph
  3. Pagination
  4. Resolved Geometry
  5. PDFBox Backend
  6. Generated PDF

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.

Built for structured business documents.

Semantic DSL

Describe modules, sections, paragraphs, tables, layers, and themes instead of manual PDF coordinates.

Automatic pagination

Let the engine split long flows, tables, and document sections across pages with deterministic placement.

Reusable templates

Compose invoices, proposals, CVs, cover letters, and operational documents from typed data specs.

Layout snapshots

Inspect resolved layout before PDF bytes are written and keep visual regressions testable.

PDFBox rendering

Render through an isolated PDFBox backend while keeping authoring and layout rules engine-owned.

Themes and visual layers

Use theme tokens, layered panels, transforms, accents, and visual hierarchy without low-level drawing code.

Advanced tables

Build business tables with row spans, zebra rows, totals, and repeated headers.

Shape containers

Place content inside clipped or rounded visual containers while preserving layout behavior.

Streaming-friendly output

Write generated PDFs to caller-owned streams for HTTP responses, storage uploads, and backend workflows.

Use GraphCompose through JitPack.

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>

Describe the document, then render it.

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();
}