lmi-commits
[Top][All Lists]
Advanced

[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>&nbsp;</td></tr>
+    <tr><td>&nbsp;</td></tr>
+    <tr><td>&nbsp;</td></tr>
+    <tr><td>&nbsp;</td></tr>
+    <tr><td>&nbsp;</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>&nbsp;</td></tr>
+    <tr><td>&nbsp;</td></tr>
+    <tr><td>&nbsp;</td></tr>
+    <tr><td>&nbsp;</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>&nbsp;</td></tr>
+    <tr><td>&nbsp;</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>&nbsp;</td></tr>
+    <tr><td>&nbsp;</td></tr>
+    <tr>
+        <td align="center">
+            <font size="+2">
+                {{date_prepared}}
+            </font>
+        </td>
+    </tr>
+    <tr><td>&nbsp;</td></tr>
+    <tr><td>&nbsp;</td></tr>
+    <tr><td>&nbsp;</td></tr>
+    <tr><td>&nbsp;</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
             );
     }
 };



reply via email to

[Prev in Thread] Current Thread [Next in Thread]