The document template is a component allowing to generate files in PDF and DOCX format.
The component is added to an entity in the form of a tab with a selector.
The documents are generated from a template in Docx or Dust format to which variables are added. To add a document, it is enough to create a new template from the document template entity. Each template must target an entity and one, or more, sub-entity.
To variabilize a document in docx format, simply create the document in a word processor (Writer, Word etc.), then add the variables specified in the help to the body of the document.
Dust documents are a web file format containing HTML. This type of document will require basic knowledge of HTML and CSS. As with the docx document, variables are inserted in the body of the document.
Documents are created and set up in the document template entity available in the "Administration" module. Each document has a name that will be brought up in the selectors, a variabilized source file and a target entity carrying the data.
Source files can be in Docx and Dust formats. A source file is composed of the fixed elements of the model and the variables that will be retrieved by the system.
It is possible to limit access to documents by specifying groups and roles on the template. Only users linked to one of the groups or roles will have access to the documents.
To retrieve all the variables accessible in the application, online help is available via the "Help" button by clicking on the button. A Dust file template is available in the application. This template gives an example of the implementation of the different data types.
The variables can take 3 forms:
{f_fieldName}
{r_entityName.f_fieldName}
{#r_entityName} {f_fieldName} {/r_entityName}
NB: The variables of type date, can be written in two ways:
- {f_field_date.value}
which return the unformatted date
- {f_field_date.converted}
which return the formatted date
Some variables in the application are called global variables. They are accessible whatever the entity set on the document. For example : {g_date}
In order to integrate images shared by the whole application into the documents, it is possible to define resource images. These images are added and uploaded in the entity of the same name in the Administration module. Once the image is added in the field of the same name, it is necessary to specify a variable in the code field.
This variable must add in the document will make it possible to trace the image in all the documents of the application whatever the target unit of the document. it is necessary to provide the image's buffer to an img HTML element : src="data:image/*;base64,{img_logo}"
The variable will be automatically prefixed with img_