5.2. Using the template editor

The template editor is recommended for both beginners and advanced users who want to create an HTML invoice template. Our support team prefers to use the editor rather than to code templates by hand.

The template editor can be used to create new templates or to edit existing ones.

  • Go to File » Template Editor to open the template editor.

  • If you've already created a template, go to the Invoices view and double-click an invoice to view it. You can then click the Edit link next to the Templates drop-down list to edit the currently used template.

    The nice thing about opening the template editor from the View Invoice window is that you can adjust the template and see how that specific invoice will look like.

The editor works with HTML templates but you don't have to know HTML to use it, although this might help if you want to adjust even the smallest details. The templates created by the template editor should not be edited outside Fanurio, adjust the meta-template instead.

Note: The template editor can only open templates it created. It cannot import old HTML templates or templates created manually. If you have an old template, it should be relatively easy to recreate it with this editor.

5.2.1. Basic settings

Most template settings can be easily changed by checking some boxes or by typing text in some fields. That's how you can specify the page format, the logo, the columns of the invoice and their names or the totals.

Headers and footers on the other hand are more complex and they may contain HTML code and placeholders for specific invoice fields. Add the following text to the Invoice/Footer field to display the invoice notes:

${invoice.notes}

Just like invoice.notes, there are many other placeholders for the fields of an invoice, your business and your client's business. The complete list of placeholders can be found here. If you want to know more about placeholders, we have a separate section that explains them.

If you want to format the text, you need to use HTML code. Add the following text to the Invoice/Footer field to display the invoice notes and a thank you note:

<p>${invoice.notes}</p>
<br/>
<p><center>Thank you for your business!</center></p>

The text between <p> and </p> represents a paragraph, <br/> represents a line-break while the text between <center> and </center> will be displayed centered. Another tag that you may want to use to format text as bold is <b> </b>. See this guide if you want to learn HTML at basic level.

5.2.1.1. Logo

  1. Go to File » Template Editor to open the template editor,

  2. Go to the Page section,

  3. Check the Logo box,

  4. Click the link next to the Logo box to specify the logo image,

  5. Click the Update button to see how it looks like and

  6. Optionally, adjust the Height and click Update again to see how the look changes.

5.2.1.2. QR-bill

QR-bill is a new standard that replaces inpayment slips throughout Switzerland starting on June 30, 2020. Invoice templates created by the template editor can be configured to show a QR-bill but only if the following data is entered in the application:

  • IBAN number: Go to Business » My Business Details and enter it in the Company / Registration / Other Number field.

  • Business name: Go to Business » My Business Details and enter it in the Company / Name field.

  • Business address: Go to Business » My Business Details and enter it in the Company / Contact / Address, City, Zip and Country fields. The country field must contain a two-letter country code to be valid. If it's missing, CH (Switzerland) is used by default.

  • Client name: Go to the Projects view and right-click (ctrl-click on macOS) a client. Then select Edit Client from the contextual menu. Enter the client name under Registration / Legal Name or Company / Name (used if Legal Name is missing).

  • Client address: Go to the Projects view and right-click (ctrl-click on macOS) a client. Then select Edit Client from the contextual menu. Enter it in the Contact / Address, City, Zip and Country fields. The country field must contain a two-letter country code to be valid. If it's missing, CH (Switzerland) is used by default.

  • Additional information (optional): If the invoice has any notes, they are displayed in the Additional information QR-bill field.

Here's how to configure templates to show the QR-bill:

  1. Go to File » Template Editor to open the template editor,

  2. Go to the Invoice section,

  3. Scroll-down and check the QR-bill box,

  4. Click the Update button to see how it looks like. The QR-bill is displayed separately on the last page of the invoice.

If you need to customize the QR-bill, you can change qrbill FreeMarker directive in the the meta-template.

5.2.1.3. PDF/A compliance

PDF/A is an ISO-standardized version of the PDF format specialized for use in the archiving and long-term preservation of electronic documents. Invoice templates created by the template editor can be configured to generate PDF/A compliant documents when exporting invoices as PDF documents.

Here's how to configure templates to be PDF/A compliant:

  1. Go to File » Template Editor to open the template editor.

  2. Go to the PDF section.

  3. Check the PDF/A Compliance box and select the PDF/A version and conformance level.

    If PDF/A-3 is selected, you can also attach a file to the PDF/A document. The Attachment box can be checked to configure the attached file.

  4. Select a font to embed in the document from the embedded fonts drop-down list.

    The list contains one default font (Liberation Sans) and the fonts available in the templates folder. If you need to embed a specific font, you must copy the font files (*.ttf) to the templates folder.

  5. Select a character encoding for the embedded font.

    Cp1252 is selected by default, it refers to the West European Latin character encoding. Other encodings are:

    • Cp1250 - East European Latin

    • Cp1251 - Cyrillic

    • Cp1252 - West European Latin

    • Cp1253 - Greek

    • Cp1254 - Turkish

    • Cp1255 - Hebrew

    • Cp1256 - Arabic

    • Cp1257 - Baltic

    • Cp1258 - Vietnamese

  6. Click the Save button to save the changes.

  7. Export an invoice to PDF with the new template to create a PDF/A document.

    PDF/A documents created by Fanurio can be validated online (Big Faceless Organization, Qoppa Software, PDF Tools AG) and offline (veraPDF).

You can also configure PDF/A compliance manually by editing the meta-template.

5.2.1.4. ZUGFeRD / Factur-X

ZUGFeRD is an electronic invoicing standard used in Germany. Starting with version 2.1, it is fully compatible with the corresponding French standard Factur-X. Fanurio supports both standards: ZUGFeRD versions 1.0, 2.0, 2.1 and Factur-X version 1.0.

In order to generate valid ZUGFeRD invoices, Fanurio expects the following data to entered:

  • VAT number: Go to Business » My Business Details and enter it in the Company / Registration / Tax Number field. Valid VAT numbers must be prefixed with the country code (e.g. DE123456789).

  • Country name: Go to Business » My Business Details and enter it in the Company / Contact / Country field. Valid country names must use the two-letter country code, for instance DE for Germany.

Here's how to configure invoice templates to create a ZUGFeRD / Factur-X invoice:

  1. Go to File » Template Editor to open the template editor.

  2. Go to the PDF section.

  3. Click the Standard drop-down list to select a ZUGFeRD version and conformance level. This will automatically configure the following PDF/A settings (explained above):

    • PDF/A compliance is enabled and set to PDF/A-3b but you can change it to PDF/A-3a or PDF/A-3u. Only PDF/A-3 conformance levels can be selected if a ZUGFeRD standard is selected.

    • Attachment is enabled and configured for the selected ZUGFeRD version with a default ZUGFeRD template. If you need to use your own ZUGFeRD template, click the Attachment link to edit it.

      For instance, if you select ZUGFeRD 1.0 BASIC then the Attachment is configured with the following expression for the Data field:

      [@einvoice invoice=invoice template='fanurio://zugferd1p0basic.ftl' base64encoded=true/]

      This expression generates the document that is attached to the ZUGFeRD invoice using the default ZUGFeRD template called fanurio://zugferd1p0basic.ftl. If you have your own ZUGFeRD template called mytemplate.ftl, you should use the following expression in the Data field:

      [@einvoice invoice=invoice template='mytemplate.ftl' base64encoded=true/]

      Custom ZUGFeRD templates like mytemplate.ftl must be located in the templates folder. You can create your own ZUGFeRD template by customizing a default template. All default ZUGFeRD templates are documented in the ZUGFeRD / Factur-X section.

    • Embedded font is enabled and set to Liberation Sans. You can select other fonts if you copy their font files (*.ttf) to the templates folder.

    • Character encoding for the embedded font is enabled and set to Cp1252.

    • Optionally, you can set Tagged to Yes.

  4. Click the Save button to save the changes.

  5. Export an invoice to PDF with the new template to create a ZUGFeRD invoice.

    ZUGFeRD documents created by Fanurio can be validated online at ZUGFeRD Community (requires registration).

You can also configure ZUGFeRD / Factur-X invoices manually by editing the meta-template.

5.2.2. Adjust the look and format using CSS (for advanced users only!)

The template editor has a CSS field in the Style section where users can enter custom CSS code to adjust the look and format of the final document. This feature is meant to be used only by people who know CSS.

Here are a few snippets that you can use to customize the invoice template.

Snippet 1: Display totals only on the last page

.table tfoot {
  display: table-row-group;
} 

If the invoice has multiple pages, totals are displayed on each page. This code changes the table to display the totals only on the last page.

Snippet 2: Force the invoice table to a certain height

.table {
  height: 12cm;
}

The invoice table height is variable and depends on what's in the table. This code forces it to have a specific height.

Snippet 3: Paint a line above the table footer (totals)

.table tfoot tr:first-child td {
  border-top: 1px solid black;
}

Use this code if you want to separate the totals from the rest of the table by drawing a line.

5.2.3. Adjust the meta-template (for advanced users only!)

An invoice template created by the template editor stores two things that allow it to be edited:

  • the settings like which columns are visible or the page format and

  • the meta-template that can process these settings to create the invoice template.

The meta-template allows you to make complex changes to your templates that can't be done by simply configuring some settings. If an invoice template is not generated the way you want it to be, you should change the meta-template instead of editing the template outside the application. The meta-template is available in the Meta-template field of the template editor.

Here are a few things that you can change in the meta-template:

  • the order of columns in the invoice table,

  • sort items by name instead of date,

  • the information displayed for some items.

The meta-template uses angle bracket tag syntax (e.g. <#directive> ... </#directive>) and square bracket interpolation syntax (e.g. [=variable]) while the actual template uses square bracket tag syntax (e.g. [#directive] ... [/#directive]) and dollar interpolation syntax (e.g. ${variable}).