Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import com.demcha.examples.templates.cv.v2.CvTimelineMinimalExample;
import com.demcha.examples.templates.invoice.InvoiceCinematicFileExample;
import com.demcha.examples.templates.invoice.InvoiceFileExample;
import com.demcha.examples.templates.invoice.v2.ModernInvoiceV2Example;
import com.demcha.examples.templates.proposal.CinematicProposalFileExample;
import com.demcha.examples.templates.proposal.ProposalCinematicFileExample;
import com.demcha.examples.templates.proposal.ProposalFileExample;
Expand Down Expand Up @@ -138,6 +139,7 @@ public static void main(String[] args) throws Exception {
// Invoices
System.out.println("Generated: " + InvoiceFileExample.generate());
System.out.println("Generated: " + InvoiceCinematicFileExample.generate());
System.out.println("Generated: " + ModernInvoiceV2Example.generate());

// Proposals
System.out.println("Generated: " + ProposalFileExample.generate());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.demcha.examples.templates.invoice.v2;

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.data.invoice.InvoiceDocumentSpec;
import com.demcha.compose.document.templates.invoice.v2.presets.ModernInvoice;
import com.demcha.examples.support.ExampleDataFactory;
import com.demcha.examples.support.ExampleOutputPaths;

import java.nio.file.Path;

/**
* Renders the layered {@code invoice.v2} Modern Invoice preset against
* the shared {@code InvoiceDocumentSpec} sample data using the default
* {@code BrandTheme.invoiceModern()} theme.
*
* <p>Output:
* {@code examples/target/generated-pdfs/templates/invoice/invoice-modern-v2.pdf}.</p>
*
* <p>This is the "hello world" for the v2 invoice pipeline: fetch sample
* data, ask the preset for a template, render it — the same shape as the
* v2 CV examples, now on the invoice family.</p>
*/
public final class ModernInvoiceV2Example {

private ModernInvoiceV2Example() {
}

/**
* @return absolute path of the rendered PDF
* @throws Exception if rendering fails
*/
public static Path generate() throws Exception {
Path outputFile = ExampleOutputPaths.prepare(
"templates/invoice", "invoice-modern-v2.pdf");
InvoiceDocumentSpec spec = ExampleDataFactory.sampleInvoice();
DocumentTemplate<InvoiceDocumentSpec> template = ModernInvoice.create();

float m = (float) ModernInvoice.RECOMMENDED_MARGIN;
try (DocumentSession document = GraphCompose.document(outputFile)
.pageSize(DocumentPageSize.A4)
.margin(m, m, m, m)
.create()) {
template.compose(document, spec);
document.buildPdf();
}
return outputFile;
}

/**
* @param args ignored
* @throws Exception if rendering fails
*/
public static void main(String[] args) throws Exception {
System.out.println("Generated: " + generate());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,23 @@ public static BrandTheme mintEditorial() {
Spacing.mintEditorial(),
Decoration.classic());
}

/**
* The "Modern Invoice" look — Helvetica, slate ink, a pale-blue
* rounded hero panel with a blue accent strip, and light table
* rules. The first layered <em>invoice</em> flavour: the invoice
* presets read it exactly the way the CV presets read their own
* flavours, so the two families share one theme model.
*
* @return a {@code BrandTheme} for the "Modern Invoice" look
*/
public static BrandTheme invoiceModern() {
return new BrandTheme(
Palette.invoiceModern(),
Typography.invoiceModern(),
Spacing.invoiceModern(),
Decoration.classic());
}
// -- pre-built text-style helpers ------------------------------------
// Renderers ask the theme for an already-composed DocumentTextStyle
// instead of re-assembling font + size + decoration + colour every
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,23 @@ public static Palette mintEditorial() {
DocumentColor.rgb(70, 70, 70), // rule (skill-bar track)
DocumentColor.rgb(139, 207, 190)); // banner — reused as mint accent
}

/**
* Modern Invoice palette: slate body ink, grey metadata, light
* table-border rules, and a pale-blue fill carried in the
* {@code banner} slot for the invoice hero panel and table zebra
* rows. The stronger accent blue used for the hero strip / status
* is preset-local in {@code ModernInvoice} because no other v2
* preset shares it today.
*
* @return a {@code Palette} for the Modern Invoice flavour
*/
public static Palette invoiceModern() {
return new Palette(
DocumentColor.rgb(33, 37, 41), // ink — slate body text
DocumentColor.rgb(108, 117, 125), // muted — metadata
DocumentColor.rgb(206, 212, 218), // rule — table borders / separators
DocumentColor.rgb(232, 240, 254), // banner — pale-blue hero panel / zebra fill
DocumentColor.WHITE); // mainFill — table surface
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -501,4 +501,31 @@ public static Spacing mintEditorial() {
0.45, // entryDateWeight
12.0); // entrySeparation (roomy editorial gap)
}

/**
* Spacing for the Modern Invoice preset: a 14pt page-flow rhythm
* matching the cinematic invoice, a rounded hero panel (10pt radius,
* 14pt inner padding), and a 4pt accent strip down the hero's left
* edge. Entry-row tokens are unused by the invoice layout but kept
* at neutral defaults for the shared record shape.
*
* @return a {@code Spacing} for the Modern Invoice preset
*/
public static Spacing invoiceModern() {
return new Spacing(
14, // pageFlowSpacing (matches the cinematic invoice)
4, // sectionBodySpacing
DocumentInsets.zero(), // sectionBodyPadding
DocumentInsets.zero(), // headlinePadding
DocumentInsets.zero(), // contactPadding
10.0, // bannerCornerRadius (hero panel radius)
14.0, // bannerInnerPadding (hero panel padding)
DocumentInsets.zero(), // bannerMargin
4.0, // accentRuleWidth (hero accent strip width)
2.0, // paragraphMarginTop
8.0, // entryHeaderRowSpacing
1.0, // entryTitleWeight
0.45, // entryDateWeight
3.0); // entrySeparation
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,24 @@ public static Typography mintEditorial() {
8.0, // body (profile / experience)
1.3); // line spacing
}

/**
* Helvetica scale for the Modern Invoice preset — a clear invoice
* title, compact bold labels (FROM / BILL TO / table header), and a
* readable body for party blocks and line-item cells.
*
* @return a {@code Typography} scale for the Modern Invoice preset
*/
public static Typography invoiceModern() {
return new Typography(
FontName.HELVETICA_BOLD, FontName.HELVETICA,
22.0, // headline (invoice title)
9.0, // contact (unused by invoice; kept for the record shape)
9.5, // banner (FROM / BILL TO / column labels)
10.0, // entry title
9.5, // entry date
9.0, // entry subtitle (footer note)
9.5, // body (party blocks, table cells)
1.3); // line spacing
}
}
Loading
Loading