Document template formats: DOCX, PDF, XLSX
Overview
Kompass renders project documents, invoice documents and report templates into one of three formats:
- DOCX: Word documents (default for most templates)
- PDF: for documents that should not be edited after generation
- XLSX: Excel spreadsheets, useful for tabular reports
The template file you upload decides which formats you can produce. A .docx template produces DOCX or PDF, and an .xlsx template produces XLSX.
DOCX templates
DOCX templates use template tags ({{ project.name }}, {% for item in quote_items %}) inside a normal Word document. Most text formatting is preserved, including bullet points and numbered lists.
Details and notes fields in Kompass support Markdown. To show it as Word formatting (bold, italic, bullets, numbered lists, links and headings) rather than raw **asterisks**, add the markdown filter, for example {{ project.details | markdown }}.
XLSX templates
XLSX templates use the same tags, placed in the cells of a spreadsheet. Typical uses include:
- Project performance reports with many rows
- Proposal Item exports formatted for a customer
- Custom invoice schedules
Tags can be placed inside any cell. To repeat a row for each item of a list (for example all Proposal Items in a project), start the loop in the row's first cell and close it in the first cell of the next row:
| A | B | |
|---|---|---|
| 2 | {% for item in quote_items %}{{ item.reference }} |
{{ item.name }} |
| 3 | {% endfor %} |
Row 2 is written once per item. A loop that opens and closes in the same cell does not add rows.
Map screenshots
Templates can include a map image of a project's map data:
- In DOCX and PDF project documents, place
{{ maps_screenshot }}where the image should appear. The image is inserted in place of the tag. - In XLSX documents, place
{{ maps_screenshot() }}(with the brackets) in a cell; the image is placed at that cell. Report templates cover many projects, so pass the map data to draw, for example{{ maps_screenshot(entry.geometries) }}.
Only the project's own map data is drawn: no other projects and no other map layers. If the project has no map data, nothing is inserted.
All settings are optional. The defaults, in a DOCX or PDF document, are:
{{ maps_screenshot(width=600, height=400, scale=2, maptype="roadmap", width_cm=15) }}
XLSX documents take the same settings except width_cm.
- width / height: size of the map area in pixels (maximum 640 each)
- scale: image quality, 1 or 2; 2 doubles the pixel density for crisp printing
- maptype:
roadmap,satellite,hybridorterrain - zoom: fixed zoom level from 0 to 21; leave it out to fit the map to the drawn data automatically
- width_cm: printed width in the document (DOCX and PDF only)
Map screenshots use Google Maps and need the map view to be set up for your account. If document generation reports a missing API key, please contact support.
Images from file fields
A user-defined file field can hold photos and other files for a record. In DOCX templates, and in PDF documents made from them, its images can be placed in the document, at their natural size or at a width or height you give in centimetres. See Files and Images in Document Templates for the tags.
PDF output
A DOCX template can be rendered to PDF, which is useful for finalised invoices and quotes. When you generate a document from a DOCX template, choose PDF as the format.
File naming
The output filename is itself a template, set when you configure the document template. You can reference project, client and date fields:
{{ project.reference }} - {{ client.name }} - quote.docx
If the name comes out empty (for example a blank reference), the document is named after the template.