Last Page Footer

Objective

Suppose we want to create an invoice form - or another report template for this matter - with some details, e.g. invoice total amounts at the bottom of the last page. How can we achieve this with Docentric?

If this document is printed on one page only, the Totals are printed at the bottom of the first page. If there are more pages, it appears only at the bottom of the last page.

When designing SSRS reports there is no Report footer either, but you can achieve it using a workaround with Page footer and the Visibility expression using Global variables – Globals!PageNumber and Globals!TotalPages. Let’s now see how we can accomplish this with Docentric.

With such a requirement, your first thought might be if Word supports this natively – i.e. can we format a last page footer? Unfortunately, there is no such built-in MS Word functionality as of now.

MS Word allows us to format three sets of headers and footers per section. Each section can have different headers and footers for the first page, even pages and all other pages. Unfortunately, there is no option to set a header/footer for the last page, which would be exactly what we need in this scenario.

Workaround using a Text Box

There is a workaround to achieve exactly this with Docentric Designer by using a floating Text Box. This Text Box will contain our Totals value.

You can do this if you follow the following steps.

  1. Move the cursor to the last paragraph in your template.
  2. Then insert a new Text Box - in the following example we have inserted a Simple Text Box.

  3. Next, we have to lock the anchor of this Text Box and position it to the bottom of the page. By doing so we only ensure the Text Box’s anchor will not move when we will be positioning the Text Box. To do so, just right-click on the box and select See more from Layout options:



    A dialog box will open where you can Lock the anchor and then set an Absolute position of this Text Box on the page - select the values that work in your case. You can also set the alignment and size of the Text Box.



    This way, the floating Text Box will always be positioned at the bottom of the last page, since this is where the (last) paragraph containing the anchor is positioned.

  4. You can then add any Word or Docentric elements to this newly created Text Box and format them according to your wishes. For testing purposes, we have inserted only a simple table with totals and the Field tagging element bound to the InvoiceAmount data field.
Pay attention to the size and position of your Text Box. It must not conflict with the main content that is printed in the body of your report, neither with any elements you might have in the footer of your document. If necessary, please change page margins and other settings accordingly. We suggest turning on the Live Preview pane to instantly observe any changes in the template. We also recommend loading different data sources (DDSP files) into the template in order to test use cases with a different number of resulting pages.

Text Box containing a dynamic element

We often have to deal with dynamically sized template elements. If a table within the Text Box contains a repeating element, such as a Group or List tagging element, its size varies depending on the number of table rows rendered during report generation.

In this case, it is a good idea to position Text Box directly above the bottom margin and set the formatting so that its height will change according to the size of the dynamically rendered table. To achieve this, click the Text Box, then click Layout > Position and choose the option Position in Bottom Center with Square Text Wrapping (steps 1-5).

Next, format Text Box to dynamically accommodate the full size of the table. Click the Text Box, then select Format > Format Text Effects > Layout and properties > Resize shape to fit text (steps 1-4). To achieve an optimal size of the Text Box in relation to the table size, you can reduce the margins of the Text Box to zero. You can then delete any remaining paragraph marks or, optionally, minimize its size to 1 point (step 5).

We also recommend to set Text Wrapping to Top and Bottom to avoid conflicts with the main content of the report.

Below is a simulation of the described Text Box formatting.

Before proceeding with the workaround, it's important to note that the Last Page Footer element created using the floating Text Box technique may not necessarily be displayed on the last page of your document if your template uses multiple sections. MS Word supports multiple sections in the documents, and in cases where your template includes content in subsequent sections after the position where our element is anchored, that content will be displayed after the Last Page Footer element. Please ensure your template structure aligns with your intended layout.

Resources

Invoice Template With Last Page Footer

IN THIS ARTICLE