[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master d99576a 069/156: Change cover page to use an
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master d99576a 069/156: Change cover page to use an external template |
Date: |
Tue, 30 Jan 2018 17:22:13 -0500 (EST) |
branch: master
commit d99576a09e144c7154a1661feb0d3ff1ae969c21
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Change cover page to use an external template
Define the page contents in the template instead of hard-coding it.
Unfortunately this means that the footer at the end of the page can't be
positioned precisely any longer.
---
cover.mustache | 129 +++++++++++++++++++++++++++++++++++
ledger_pdf_generator_wx.cpp | 163 ++++----------------------------------------
2 files changed, 142 insertions(+), 150 deletions(-)
diff --git a/cover.mustache b/cover.mustache
new file mode 100644
index 0000000..bcbc561
--- /dev/null
+++ b/cover.mustache
@@ -0,0 +1,129 @@
+<table width="100%">
+ <!--
+ Rows such as this are used as separators between visible table elements,
+ this is unfortunately necessary because wxHTML doesn't support
+ margin/padding on table elements.
+ -->
+ <tr><td> </td></tr>
+ <tr><td> </td></tr>
+ <tr><td> </td></tr>
+ <tr><td> </td></tr>
+ <tr><td> </td></tr>
+ <tr>
+ <td align="center">
+ <font size="+4">
+ <b>{{PolicyMktgName}}</b>
+ </font>
+ </td>
+ </tr>
+ <tr>
+ </tr>
+ <tr>
+ <td align="center">
+ <font size="+4">
+ <b>
+ {{#IsInforce}}
+ In Force Life Insurance Illustration
+ {{/IsInforce}}
+ {{^IsInforce}}
+ Life Insurance Illustration
+ {{/IsInforce}}
+ </b>
+ </font>
+ </td>
+ </tr>
+ <tr><td> </td></tr>
+ <tr><td> </td></tr>
+ <tr><td> </td></tr>
+ <tr><td> </td></tr>
+ <tr>
+ <td align="center">
+ <font size="+2">
+ <b>Prepared for:</b>
+ </font>
+ </td>
+ </tr>
+ <tr>
+ <td align="center">
+ <font size="+2">
+ {{#Composite}}
+ {{CorpName}}
+ {{/Composite}}
+ {{^Composite}}
+ {{Insured1}}
+ {{/Composite}}
+ </font>
+ </td>
+ </tr>
+ <tr><td> </td></tr>
+ <tr><td> </td></tr>
+ <tr>
+ <td align="center">
+ <font size="+2">
+ <b>Presented by:</b>
+ </font>
+ </td>
+ </tr>
+ <tr>
+ <td align="center">
+ <font size="+2">
+ {{ProducerName}}
+ </font>
+ </td>
+ </tr>
+ <tr>
+ <td align="center">
+ <font size="+2">
+ {{ProducerStreet}}
+ </font>
+ </td>
+ </tr>
+ <tr>
+ <td align="center">
+ <font size="+2">
+ {{ProducerCity}}
+ </font>
+ </td>
+ </tr>
+ <tr><td> </td></tr>
+ <tr><td> </td></tr>
+ <tr>
+ <td align="center">
+ <font size="+2">
+ {{date_prepared}}
+ </font>
+ </td>
+ </tr>
+ <tr><td> </td></tr>
+ <tr><td> </td></tr>
+ <tr><td> </td></tr>
+ <tr><td> </td></tr>
+</table>
+
+<!--
+This is ugly and error-prone, but there is no way to put the paragraph below at
+the bottom of the page currently, so we just insert enough white space to push
+it roughly where we want it to appear.
+-->
+<br></br>
+<br></br>
+<br></br>
+<br></br>
+<br></br>
+<br></br>
+<br></br>
+<br></br>
+<br></br>
+<br></br>
+<br></br>
+<br></br>
+<br></br>
+<br></br>
+
+<p align="center">
+ <font size="-1">
+{{InsCoShortName}} Financial Group is a marketing
+name for {{InsCoName}} ({{InsCoShortName}}) and its
+affiliated company and sales representatives, {{InsCoAddr}}.
+ </font>
+</p>
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 0115c47..eb3b3fe 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -506,166 +506,29 @@ class cover_page : public page
{
public:
void render
- (Ledger const& ledger
+ (Ledger const& /* ledger */
,pdf_writer_wx& writer
,html_interpolator const& interpolate_html
) override
{
+ int const height_contents = render_page_template
+ ("cover"
+ ,writer
+ ,interpolate_html
+ );
+
+ // There is no way to draw a border around the page contents in wxHTML
+ // currently, so do it manually.
auto& dc = writer.dc();
dc.SetPen(wxPen(HIGHLIGHT_COL, 2));
dc.SetBrush(*wxTRANSPARENT_BRUSH);
- auto const frame_horz_margin = writer.get_horz_margin();
- auto const frame_vert_margin = writer.get_vert_margin();
- auto const frame_width = writer.get_page_width();
- auto const frame_height = writer.get_page_height();
-
dc.DrawRectangle
- (frame_horz_margin
- ,frame_vert_margin
- ,frame_width
- ,frame_height
- );
-
- auto const& invar = ledger.GetLedgerInvariant();
-
- // We use empty table cells to insert spaces into the table below.
- auto const space = tag::tr(tag::td(text::nbsp()));
-
- auto const cover_html =
- tag::table[attr::width("100%")]
- (tag::tr
- (tag::td[attr::align("center")]
- (tag::font[attr::size("+4")]
- (tag::b(text::from(invar.PolicyMktgName))
- )
- )
- )
- )
- (tag::tr
- (tag::td[attr::align("center")]
- (tag::font[attr::size("+4")]
- (tag::b
- (text::from
- (invar.IsInforce
- ? "In Force Life Insurance
Illustration"
- : "Life Insurance Illustration"
- )
- )
- )
- )
- )
- )
- (space)
- (space)
- (tag::tr
- (tag::td[attr::align("center")]
- (tag::font[attr::size("+2")]
- (tag::b
- (text::from("Prepared for:")
- )
- )
- )
- )
- )
- (tag::tr
- (tag::td[attr::align("center")]
- (tag::font[attr::size("+2")]
- (text::from
- (ledger.is_composite()
- ? invar.CorpName
- : invar.Insured1
- )
- )
- )
- )
- )
- (space)
- (space)
- (tag::tr
- (tag::td[attr::align("center")]
- (tag::font[attr::size("+2")]
- (tag::b
- (text::from("Presented by:")
- )
- )
- )
- )
- )
- (tag::tr
- (tag::td[attr::align("center")]
- (tag::font[attr::size("+2")]
- (text::from(invar.ProducerName)
- )
- )
- )
- )
- (tag::tr
- (tag::td[attr::align("center")]
- (tag::font[attr::size("+2")]
- (text::from(invar.ProducerStreet)
- )
- )
- )
- )
- (tag::tr
- (tag::td[attr::align("center")]
- (tag::font[attr::size("+2")]
- (text::from(invar.ProducerCity)
- )
- )
- )
- )
- (space)
- (tag::tr
- (tag::td[attr::align("center")]
- (tag::font[attr::size("+2")]
- (interpolate_html("{{date_prepared}}")
- )
- )
- )
- )
- ;
-
- auto const text_horz_margin = 2*frame_horz_margin;
- auto const text_width = frame_width - 2*frame_horz_margin;
- writer.output_html
- (text_horz_margin
- ,4*frame_vert_margin
- ,text_width
- ,cover_html
- );
-
- auto const footer_html = tag::p[attr::align("center")]
- (tag::font[attr::size("-1")]
- (interpolate_html
- (R"(
-{{InsCoShortName}} Financial Group is a marketing
-name for {{InsCoName}} ({{InsCoShortName}}) and its
-affiliated company and sales representatives, {{InsCoAddr}}.
-)"
- )
- )
- );
-
- // Compute the footer height (which depends on how long it is, as it
- // can be wrapped to take more than one line)...
- int const footer_height = writer.output_html
- (text_horz_margin
- ,0
- ,text_width
- ,footer_html
- ,e_output_measure_only
- );
-
- // ... in order to be able to position it precisely at the bottom of
- // our blue frame.
- writer.output_html
- (text_horz_margin
- ,frame_vert_margin + frame_height - footer_height
- ,text_width
- ,footer_html
+ (writer.get_horz_margin()
+ ,writer.get_vert_margin()
+ ,writer.get_page_width()
+ ,height_contents
);
}
};
- [lmi-commits] [lmi] master b1ab0fa 126/156: Leave a gap between upper footer part and main page contents, (continued)
- [lmi-commits] [lmi] master b1ab0fa 126/156: Leave a gap between upper footer part and main page contents, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 940198c 059/156: Add numeric summary attachment page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master b341a2a 061/156: Factor out using_illustration_table helper class, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 1b46585 076/156: Use MarketingNameFootnote & StateMarketingImprimatur on cover page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 234cd39 012/156: Use custom font sizes to be closer to the existing illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 956fcca 071/156: Change the second narrative summary page to use a template too, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master dbe5955 015/156: Factor out html_interpolator from pdf_illustration, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 9665573 070/156: Change narrative summary page to use an external template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master a629602 083/156: Use custom <scaled_image> HTML tag for the embedded images, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master b425030 082/156: Factor out html_cell_for_pdf_output from numeric_summary_table_cell, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d99576a 069/156: Change cover page to use an external template,
Greg Chicares <=
- [lmi-commits] [lmi] master 416ab02 030/156: Add support for vector variables to PDF generating code, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d4dfaa9 075/156: Also use data directory for image files referenced from HTML, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 4f98db5 081/156: Don't show "Age 70" row in numeric summary for composites, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master f8853b9 090/156: Add "contract numbers" fragment to the header, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 61430d2 092/156: Move some variable definitions to the base illustration class, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 7ccd207 087/156: Rename "footer_contents" to more precise "page_number", Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 3a64b87 094/156: Correct misleading comment for page class dtor, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 4e76bba 098/156: Add support for comments to the string interpolation function, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master b5fe850 102/156: Add NASD basic illustration page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 4250de9 104/156: Add first variant of NASD supplemental page, Greg Chicares, 2018/01/30