IMPORTANT: This documentation has been discontinued. Read the updated HTML to PDF documentation on our new documentation portal.
HTML to PDF allows the creation of files in PDF format from a HTML.
Besides, the component uses Apache FreeMaker templates to generate the HTML through the pipeline JSON message.
Take a look at the configuration parameters of the component:
File Name: name of the PDF file to be generated in the output of the component execution.
Body: HTML template to be interpreted to generate the PDF file (this field supports the FreeMarker template).
Fail On Error: if the option is enabled, the execution of the pipeline with error will be interrupted; otherwise, the pipeline execution proceeds, but the result will show a false value for the “success” property.
Secured PDF: if the option is enabled, the insertion of a password in the PDF file is allowed to generate a protected document.
Password: password to protect the PDF file.
Custom permissions: if the option is enabled, many options of access permission in the PDF file become available; otherwise, the PDF file will be generated with all the permissions.
Read only: access permission that defines the PDF file as "read only". If the option is enabled, all the other access permissions will be disabled.
Assemble document: allows pagges to be added, rotated e deleted from the file.
Modify: allows the file to be modified.
Modify annotations: allows text notes to be added or modified in the file.
Extract content: allows texts and images to be extracted from the file.
Extract for accessibility: allows texts and images to be extracted from the file for accessibility matters.
Print: allows the file to be printed.
Print degraded: allows the file to have a degraded printing.
Fill in Form: allows forms to be filled with interactive fields.
Messages flow
Input
The component accepts any input message, being able to use it through Double Braces.
Output
successful
{ "success": true,
"fileName": "pdf_gerado.pdf", }
unsuccessful
{ "success": false,
"message": "Could not generate the pdf file",
"error": "java.net.IOException"}
Example of request response with error
{ "success": false, "message": "Could not generate the pdf file", "error": "java.net.IOException:"}
success: “false” when the operation fails
message: message about the error
exception: information about the occurred error
Example:
Body
<p>We have these animals:<table border=1>
<#list animals as animal>
<tr><td>${animal.name}<td>${animal.price} Euros
</#list></table>
Therefore, in the input message an object array is received and it has the properties “name” and “price”:
[{ "name": "Dog", "price": 100},
{ "name": "Cat", "price": 100},
{ "name": "Bird", "price": 30},]
The template will make the iteration in this received array and fill the HTML:
<p>We have these animals:<table border=1>
<tr><td>Dog<td>$100 Euros<tr><td>Cat<td>$100 Euros
<tr><td>Bird<td>$30 Euros
</table>
IMPORTANT:
SVG
To use the SVG as HTML tag, apply the following property inside the SVG tag (xmlns="http://www.w3.org/2000/svg"):
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="180"> <rect x="50" y="20" rx="20" ry="20" width="150" height="150" style="fill:red;stroke:black;stroke-width:5;opacity:0.5" /> Sorry, your browser does not support inline SVG.</svg>
CSS
Versions after 2.1 aren't supported.
IMAGES
The use of imagens in base64 format inside HTML tags isn't supported.
Eg.: <img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAA…>
You can use images with local and remote reference:
Local Image
<img src="image.jpg" alt="IMAGE2" >
In the example above, there must be a image file with the exact same name specified inside the src tag (image.jpg)
Remote Image
<img src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png" alt="IMAGE2" >