The Templating Application allows to invoke Velocity or MS Word DOCX templates with Process Data and if required convert the output into PDF format.
A template is a document, such as a personalized form letter/email/report that is sent to many customers. Templates allow business people to have more control regarding document content and format. More details about template creation are described here.
You can perform following operations on a Templating Application.
Following properties should be specified:
Figure: Properties - Templating Application
The UUID and ID options are displayed only when you switch to Integrator profile.
You can define parameters to access the data associated with the application.
The Templating Application only allows for one Output Parameter of type Text, which is
representing the response content of the Velocity Template invocation.
It allows for multiple Input Parameters. Input Parameters can be document or primitive/structured data,.
Click the Add
icon to add the parameters.
To delete the parameters, select the added parameter and click the Delete
icon.
Figure: Properties - Parameters
In the Configuration tab, you specify the template location, format and content. It's also possible to indicate whether the template output should be converted into PDF format.
In the following example, an embedded template content is convert to PDF and attached to the process instance using the specified output file name.
Figure: Properties - Embedded Configuration
At runtime, the pdf attachment looks similar to the following sample
Figure: PDF Template output sample
The template could be located in the class path as shown below:
Figure: Properties - Class Path Configuration
In the following example, an embedded XML template content is used and the result is attached to the process instance using the specified output file name.
Figure: Configuration - Embedded XML template
Figure: XML document output
In the following example, an embedded HTML template content is used and the result is converted into PDF format and attached to the process instance using the specified output file name.
Figure: Configuration - Embedded HTML template
Figure: HTML converted to PDF output
In case, the Convert to PDF check box is not enabled, the output document will be in HTML format.
Figure: HTML converted to PDF output
In the following example, a DOCX template content is used and the result is converted into PDF format and attached to the process instance using the specified output file name.
Figure: Configuration - DOCX template configuration
The DOCX template file is located in the repository under the Root/artifacts/templates folder.
Figure: Template repository location
The DOCX template is created using MS Word; a sample file is shown below
Figure: DOCX Sample template
A sample DOCX output converted to PDF format is shown below:
Figure: DOCX output converted to PDF format
In many situations, the end user would like to specify the Template and/or the Output Name dynamicaly (i.e. at runtime). This also allows the same templating application to be used with multiple template files at runtime.
Here are the main steps to follow:
Figure: Dynamic Template Configuration
If you want to provide template file name and/or Output Name dynamically through structured data type, then use expressions such as: $simple{header.Person[template]} and/or $simple{header.Person[outputName]}.
Figure: Dynamic Template Configuration with SDT
Click the Comments tab to add comments for the application. To add the comment, specify the comment in the text box and click Submit. To delete a comment, select it and click the Delete icon. The user, who has submitted the comment, can delete that comment. If the other user selects the comment or no comment is selected, the Delete icon remains in disabled state.
To create Velocity Templates having text, xml or html format, you can use your preferred text editor.
Figure: Html Template
More details about the Velocity Template Language (VTL) could be found here.
MS Word DOCX template can be easily created using MS Word as follow.
Figure: DOCX Template Creation
To use templating application you have to add the following dependencies in your pom.xml file:
<dependency> <groupId>com.infinity.integration</groupId> <artifactId>camel-templating</artifactId> <version>2.1.1</version> </dependency> <dependency> <groupId>com.infinity.integration</groupId> <artifactId>camel-itext-convertor</artifactId> <version>2.1.1</version> </dependency>