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 @@ -84,6 +84,7 @@
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.v2.ModernProposalV2Example;
import com.demcha.examples.templates.proposal.ProposalFileExample;
import com.demcha.examples.templates.schedule.WeeklyScheduleFileExample;

Expand Down Expand Up @@ -144,6 +145,7 @@ public static void main(String[] args) throws Exception {
// Proposals
System.out.println("Generated: " + ProposalFileExample.generate());
System.out.println("Generated: " + ProposalCinematicFileExample.generate());
System.out.println("Generated: " + ModernProposalV2Example.generate());
System.out.println("Generated: " + CinematicProposalFileExample.generate());

// Schedule
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.demcha.examples.templates.proposal.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.core.theme.BrandTheme;
import com.demcha.compose.document.templates.data.proposal.ProposalDocumentSpec;
import com.demcha.compose.document.templates.proposal.v2.presets.ModernProposal;
import com.demcha.examples.support.ExampleDataFactory;
import com.demcha.examples.support.ExampleOutputPaths;

import java.nio.file.Path;

/**
* Renders the layered {@code proposal.v2} Modern Proposal preset against
* the shared {@code ProposalDocumentSpec} sample data using the default
* {@code BrandTheme.proposalModern()} theme on the cream page background.
*
* <p>Output:
* {@code examples/target/generated-pdfs/templates/proposal/proposal-modern-v2.pdf}.</p>
*
* <p>The "hello world" for the v2 proposal pipeline: fetch sample data,
* ask the preset for a template, render it — the same shape as the v2 CV
* and invoice examples, now on the proposal family.</p>
*/
public final class ModernProposalV2Example {

private ModernProposalV2Example() {
}

/**
* @return absolute path of the rendered PDF
* @throws Exception if rendering fails
*/
public static Path generate() throws Exception {
Path outputFile = ExampleOutputPaths.prepare(
"templates/proposal", "proposal-modern-v2.pdf");
ProposalDocumentSpec spec = ExampleDataFactory.sampleProposal();
BrandTheme theme = BrandTheme.proposalModern();
DocumentTemplate<ProposalDocumentSpec> template = ModernProposal.create(theme);

float m = (float) ModernProposal.RECOMMENDED_MARGIN;
try (DocumentSession document = GraphCompose.document(outputFile)
.pageSize(DocumentPageSize.A4)
.pageBackground(theme.palette().mainFill())
.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 @@ -336,6 +336,27 @@ public static BrandTheme invoiceModern() {
Spacing.invoiceModern(),
Decoration.classic());
}

/**
* The "Modern Proposal" look — the same cinematic "modern business"
* surfaces as {@link #invoiceModern()} (cream page, soft-tan panels,
* deep-teal title + table headers, gold accent) with the richer h1 /
* h2 / h3 type scale a proposal needs. Mirrors the cinematic
* {@code builtins.ProposalTemplateV2}.
*
* <p>Reuses the invoice palette + spacing tokens — the two families
* share one modern business look; a future cleanup may rename those
* shared factories to a neutral {@code businessModern()}.</p>
*
* @return a {@code BrandTheme} for the "Modern Proposal" look
*/
public static BrandTheme proposalModern() {
return new BrandTheme(
Palette.invoiceModern(),
Typography.proposalModern(),
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 @@ -382,4 +382,26 @@ public static Typography invoiceModern() {
11.0, // body (party blocks, table cells — modern body)
1.3); // line spacing
}

/**
* Helvetica scale for the Modern Proposal preset — the same modern
* business face as the invoice, with the richer heading ladder a
* proposal needs: a 28pt title (h1), 17pt section headings (h2 — the
* {@code banner} slot), and a 13pt project subtitle (h3 — the
* {@code entryTitle} slot).
*
* @return a {@code Typography} scale for the Modern Proposal preset
*/
public static Typography proposalModern() {
return new Typography(
FontName.HELVETICA_BOLD, FontName.HELVETICA,
28.0, // headline (proposal title — modern h1)
10.0, // contact (unused by proposal)
17.0, // banner (section headings — modern h2)
13.0, // entry title (project subtitle — modern h3)
11.0, // entry date (unused)
10.0, // entry subtitle (footer caption — modern caption)
11.0, // body (summary, sections, parties, cells — modern body)
1.3); // line spacing
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/**
* Proposal document specs and supporting data records for canonical templates.
* Shared, render-neutral proposal document specs and supporting data
* records, consumed by both the cinematic builtin {@code ProposalTemplateV2}
* and the layered {@code proposal.v2} presets.
*/
package com.demcha.compose.document.templates.data.proposal;
Loading
Loading