To generate a PDF and manage templates, the role “pdfPlugin” has to be assigned to your user.
You can build a PDF Template by using HTML, CSS and JSON. A live preview is provided on the right, so you can see changes in real-time.
The rendering is executed with wkhtmltopdf, therefore every HTML format and feature that supports the QT Webkit render engine is working.
With every template, a stylesheet in LESS format is generated and will be embedded automatically. You can maintain this stylesheet via the same interface as the HTML template.
The inclusion of graphics (<img src=”…”>) and additional stylesheets (<link rel=”stylesheet” href=”…”>) is also supported.
These external asserts are retrieved via the “assets” slot of the AppServer (they should be uploaded there in advance). You can refer to them in the template with a relative filename (no “http://” prefix, no path, etc.!).
Example: <img src=”image.jpg”> (if the file was uploaded as “image.jpg”)
Furthermore, you can add expressions in mustache format. These “variables” are later replaced by values from the update file to a session.
The dynamic data is retrieved as a JSON string in the key-value-store with the key: “sessiondata/$session“.
($session = the session ID that is specified for the generation)
You can combine your PDF document with other PDFs or images from the key-value store.
For this purpose, you can call the list of all the resources you want to merge with the key “merge/$session” in the key-value store. The list should correspond to a JSON-Array, where the entries of the JSON-Array are the keys of the resources to be merged. For example: [“document1.pdf”, “document2.pdf”, “image.jpg”].
The binary data of the corresponding documents should be filed in the key-value store under the keys “document2.pdf”, “document2.pdf” and “image.jpg”.
If the list of merge resources is not found for a session or if the list is empty, the merge is skipped.
Saving the generated PDF
After a PDF has been successfully generated, the binary data is stored in the Key-Value Store under the key “pdf/$jobid.pdf“. ($jobid = the job ID, that will be returned after the generation has started)
If the generation can not be executed successfully due to an error, a fault reporting is stored under the key “pdf/$jobid.log” in the key-value store.