Generate Multi-Page Invoice from Template

A multi-page invoice with a calculated Total and calculated Payment Due Date.

The table will "grow" as data is injected and if the table runs over the page the table header row will appear at the top of each new page.

This example in detail

This example uses Docmosis repeating rows, calculations, and number formatting.

The invoice also uses a header and footer, and describes how to use a table header row.

Dynamic table

The data has an array of "items" to define the Qty/Item/Amount (JSON example):

    "ItemName":"ACP101 Accounting Package",
    "itemDescription":"Annual Subscription to Premier Version with Tax, Inventory and Payroll Plugins",
  {  etc...

Rows will be dynamically added to the table to match the number of "items" in the data.

The <<rr_  repeating rows directive and the <<er_ directive will be removed from the final document and the rows between them are the ones that will be repeated.

Shading the <<rr_ repeating rows and the next row in different colors will trigger Docmosis to use alternating row colors.

Headers and footers

This template uses the header and footer feature found within Microsoft Word/LibreOffice.

The header incorporates a simple table with invisible borders to position the static logo image and the invoice details (invoice number, date and purchase order) which show at the top of each page.

The footer section of the invoice uses the inbuilt page numbering feature of Microsoft Word/LibreOffice.

Calculations and number formatting

Numbers in the data are not formatted (JSON Example):


In the template, the numFormat function is used to display a leading dollar sign, comma separated thousands, and two digits after the decimal point:


The $total is a Docmosis variable. As Docmosis loops through the items the amt is added to the $total. After all the items have been displayed the $total is formatted to display the Total.

The Payment Due By date is calculated by adding 14 days to the invoiceDate.

Table header row

The first row is set to repeat as a header row at the top of each page.

This is achieved using a Table Properties setting available in Microsoft Word or LibreOffice that Docmosis will recognize and obey.

In Microsoft Word, select "Repeat as header row at the top of each page" in the Table Properties.

In LibreOffice, select "Repeat heading" in the Table Properties.


Invalid Input

Sorry, this field will only accept letters and numbers, and not special characters, to limit spam. Please also consider contacting if you need help with this article.

Sorry, this field will only accept letters and numbers, and not special characters, to limit spam.

Invalid Input

Document Gallery

Docmosis showcases its template-based document generation capabilities through a gallery of downloadable PDF documents. The gallery features a mixture of real documents provided by customers as well as links to PDFs generated from example templates, desgined to illustrate the versatility of Docmosis.