Document formatters transform templates into output documents; e.g. an HTML invoice template can be transformed into an HTML file with the details of the invoice filled out. LedgerSMB comes with a number of built-in formatters. Additional ones could be implemented to transform HTML documents to PDF (replacing the traditional LaTeXto PDF) or the creation of eInvoices in the format of the local jurisdiction.
The generation of output entails these steps (preceded by the process to find a suitable document formatter):
Loading the input template from the database
Preprocessing the input variables using the formatter’s encode function
Initializing the template expansion using the formatter’s setup function
Expanding the template using Template::Toolkit
Post-processing the expanded output using the formatter’s postprocess
A custom formatter needs to implement the protocol as documented at https://docs.ledgersmb.org/perl-api/1.11.0/LedgerSMB/Template.pm.html#FORMATS.