The template rendering addon is an addon available from the Nuxeo Marketplace that enables users to create documents from a template, with content being automatically extracted from Nuxeo, and to have an automated rendering generated from a set of user-defined preferences. This addon includes:
- four new document types:
- two template document types, called "Template" and "Web template",
- two file-based document types, called "Customer reference" and "Statement reference" and configured using Studio,
- templates with template attachments, leveraging the Template and Web Template document types, in the "Templates" space,
- documents based on these templates, showing the result of the different template rendering options, in the "Template usage samples" workspace.
The principle of the template rendering feature is the following:
- A template file (Word file, OpenOffice.org file, ...) is created outside Nuxeo. This file holds some fields that will automatically be filled in with content defined in Nuxeo.
- A Nuxeo user creates a Nuxeo template, to which he attaches the template file (or fills in the Note content in case of a web template). He fills in the template properties, that will define under which conditions the template is available: for which document types, under which circumstances...
- When users in Nuxeo create a new document for which a template is available, they can use it. If some template elements are left to be edited or filled in by the document's contributors, they can set them.
There are two types of Nuxeo templates: the "Template" will have an attached file in which some values are defined to be Nuxeo values. The "Web template" doesn't have an attachment. Its content is defined in a Note field.
Creating a template file
The template file is the file that will be used to generate the rendering of the Nuxeo document and will be completed automatically with the defined Nuxeo properties. This template file can be:
- an office document (.doc, .docx, .odt, .xls, .xlsx, .ods formats are supported for now),
- an HTML file,
- a XML file.
To create a template file:
- Create a regular office, HTML or XML file with your favorite tool.
- In the document, put variables where you want to use information from Nuxeo (see below). You may want to use XDocReport or JXLS for this part.
- When the template is ready, create the template document in Nuxeo and attach the template to it.
Here are a few examples of the most common variables:
${doc.title
}: gets the title of the Nuxeo document${doc['dc:description']
}: gets the content of the Description field of the Nuxeo document${doc['dc:modified']
}: gets the last modification date of the Nuxeo document. You can define how the date should be formatted by adding?date
to display only the date, or?time
to display only the time. By default, the modification date displays both the date and the time.${doc.versionLabel
}: displays the version number
${auditEntries.eventId
}: displays the events listed in the document's history. ${auditEntries.eventDate
} displays the date at which the events took place, ${auditEntries.principalName
} the name of the user who did the action, ${auditEntries.comment
} the comment typed by the user.
- More information about the variables available (including functions) in the Quick user guide on the Nuxeo GitHub repository.
- XDocReport overview and docx format user guide / odt format user guide: XDocReport is a tool that enables to insert fields in MS Office and OpenOffice / LibreOffice text files.
- JXLS website: JXLS is a tool that enables to insert fields in MS Office and OpenOffice / LibreOffice spreadsheets.
- Template rendering readme file on the Nuxeo GitHub repository
- Template rendering Quick User Guide on the Nuxeo GitHub repository
Creating the template document
When the template file is done, you need to create a template document and attach the template file to it. Templates can be created in the Templates space, in workspaces and in folders.
To create a template document:
- In the Content tab of the workspace or template space, click on the New Document button.
- On the window Available document types, click on the desired document.
- Fill in the template document's creation form (see below for template's properties).
- Click on the Create button. The Summary tab of the template document is displayed. You can now create documents based on this template.
Template properties
Field | Description |
---|---|
Title | Type the template title |
Description | What the template is about |
Content | For a Template : the attached template file (odt, doc, etc file). For a web template: The Note that will hold the content of the template. Typically this would be HTML text. |
Simple mode | |
Template usage | Select what the template will be used for: Office template: Office template with PDF rendering: * Create a rendition: |
Advanced mode | |
Nature | Select which nature will the document based on the template automatically get. |
Document types for which the template is available | Select the document types for which this template will be suggested. |
Allow parameters override | Check if the user should be able to change the parameters defined here. |
Template processor | Select how are the template file fields processed to use Nuxeo data. Automatic should work for most file formats. XDocReport is specifically target at text file formats: doc, docx, odt. JXLS is used for spreadsheet file formats: xls, xlsx, ods. |
Rendition | Select the views that will be available for the template. |
Document types automatically associated to template | Select the document types for which the template file will automatically be attached. |
Template is editable on the document (office template) | If checked, the user will be able to ? |
Rendering output format | Select what is the format of the selected rendition going to be. |
Using template documents
A document can use one or several templates. If it is associated with several templates, the first template associated is considered as the main template and is used as content. The other associated templates are used to generate additional renditions of the document. When a document is using a template, an additional tab is available on the document, called Associated templates. There are several ways to associate a template to a document.
Creating a document based on a template
To create a new document based on a template, users need to use the New document button. If a template is available for the selected document type, an additional option is then available for the Content field, allowing users to select which template to use.
Users can then:
- associate other templates to the document,
- render the document using the template(s),
- publish the document using the template's available renditions.
Associating a template to a document
It is possible to associate a document with a template after the document's creation.
To associate a document to a template:
- If the document has no template associated yet:
- Click on the icon .
- Select the template to use and click on Bind template.
- If the document already has at least one associated template:
- Click on the Associated templates tab.
- Click on the link Add a template.
- Select the new template to associate with the document and click on the button Bind template.
The Summary tab is displayed. The added template is displayed in the Associated templates section of the Summary tab.
Rendering a document using its template
When a document has one or several templates associated, it is possible to view or download the document using the rendition(s) defined by the templates. The available renditions depend on the template you chose to use.
To view the document using a rendition, click on the corresponding rendition in the Renditions of the Summary tab.
Publishing a document's rendition
The Template rendering addon enables to publish a rendition of the document instead of the document itself, as it is the case on a default Platform configuration. Typically, it enables to publish the PDF rendition of an office document.
To publish a rendition of a document:
- Click on the Publish tab of the document.
An additional Publish a rendition drop down list is available beside the usual list of sections.
- In the Publish a rendition drop down list, select the rendition you want to publish.
- Unfold the sections tree and click on the Publish here link corresponding to the section you want to publish the document in. The document's rendition is submitted to publishing and must approved using the usual publishing process.
If you use the multi-tenant add-on at the same time, you should be aware that due to some technical limitations, models bound to a given document type are bound whatever the tenant the model is stored in.