Modern Invoice
The ModernInvoice preset composed straight from an InvoiceDocumentSpec — line items, totals and payment block driven by the BrandTheme rather than per-document styling.
1 page
Use this template
<dependency>
<groupId>io.github.demchaav</groupId>
<artifactId>graph-compose</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>io.github.demchaav</groupId>
<artifactId>graph-compose-templates</artifactId>
<version>2.4.1</version>
</dependency>
implementation 'io.github.demchaav:graph-compose:2.4.1'
implementation 'io.github.demchaav:graph-compose-templates:2.4.1'
Java 17 or newer
Preset com.demcha.compose.document.templates.invoice.presets.ModernInvoice
Data model com.demcha.compose.document.templates.data.invoice.InvoiceDocumentSpec
import com.demcha.compose.GraphCompose;
import com.demcha.compose.document.api.DocumentPageSize;
import com.demcha.compose.document.api.DocumentSession;
import com.demcha.compose.document.templates.api.DocumentTemplate;
import com.demcha.compose.document.templates.core.theme.BrandTheme;
import com.demcha.compose.document.templates.data.invoice.InvoiceDocumentSpec;
import com.demcha.compose.document.templates.invoice.presets.ModernInvoice;
import java.nio.file.Path;
InvoiceDocumentSpec invoice = InvoiceDocumentSpec.builder()
.title("Invoice")
.invoiceNumber("GC-2026-041")
.issueDate("25 Jun 2026")
.dueDate("25 Jul 2026")
.reference("GraphCompose implementation")
.status("Due")
.fromParty(party -> party
.name("GraphCompose Studio")
.addressLines("10 Example Street", "London")
.email("billing@example.com")
.phone("+44 20 0000 0000")
.taxId("VAT GB000000000"))
.billToParty(party -> party
.name("Client Ltd")
.addressLines("22 Client Road", "Manchester")
.email("accounts@client.example"))
.lineItem("Document engine integration", "Implementation and support",
"1", "4,800.00", "4,800.00")
.summaryRow("Subtotal", "4,800.00")
.summaryRow("VAT", "960.00")
.totalRow("Total", "5,760.00")
.paymentTerm("Payment due within 30 days.")
.footerNote("Thank you for your business.")
.build();
BrandTheme theme = BrandTheme.invoiceModern();
DocumentTemplate<InvoiceDocumentSpec> template = ModernInvoice.create(theme);
float margin = (float) ModernInvoice.RECOMMENDED_MARGIN;
try (DocumentSession document = GraphCompose.document(Path.of("invoice.pdf"))
.pageSize(DocumentPageSize.A4)
.pageBackground(theme.palette().mainFill())
.margin(margin, margin, margin, margin)
.create()) {
template.compose(document, invoice);
document.buildPdf();
}
./mvnw -f examples/pom.xml exec:java -Dexec.mainClass=com.demcha.examples.templates.invoice.v2.ModernInvoiceV2Example
Writes examples/target/generated-pdfs/templates/invoice/invoice-modern-v2.pdf