Templator - Document (PDF) and report generation alternative
Overview
Documentation
Full documentation available at
https://www.notion.so/gajduk/Templator-d35db3ba165346e3b243d6695636ccd4
For pricing and licensing questions contact Mansystems at
https://www.mansystems.com/contact#contact-us
Getting Started
-
Build a standard Mendix page using the DocumentLayout. You can use any Mendix standard or app store widgets and any CSS when designing the page.
-
Declare a microflow that opens the page from step1.
-
Use the microflow action Generate PDF to get a beautiful looking PDF file!
Step-by-step video tutorial https://youtu.be/rARB6R4oWnE
Compatibility
The module is compatible with all supported Mendix versions.
PDF Options
Additional Options can be passed when generating PDF to define margins, header/footer and more. Please refer to this document for an extensive list of all options https://github.com/puppeteer/puppeteer/blob/v2.1.0/docs/api.md#pagepdfoptions
Debugging
The templator only works for apps that are publicly accessible i.e. have a public IP address. This is not the case when running locally. If you wish to test how a PDF will look like without having to deploy to the cloud there are two possibilities:
One option is to run locally and expose the microflow that you are trying to generate PDF from as a button on a page. Then open the latest Chrome browser, click on the button then press Ctrl + P (or ⌘+P if you are on Mac) and choose Destination: Save as PDF. Since templator uses the same PDF engine as Chrome, the two PDFs should be identical provided that all the options are the same.
Alternatively, you can use a tool such as ngrok or localtunnel to expose your local 8080 port where Mendix applications run by default. If you decide to use this method you will need to set the constant ApplicationURLOverrideOPTIONAL to your ngrok URL so that templator knows where to find your app.
Data privacy
In order to generate documents, the templator is given restricted and temporary access to the app for the specified user. This access is secured and limited to 60 seconds or until the PDF is generated.
The templates themselves may contain sensitive or personal data that is sent over a network. All data sent over the network is encrypted. Any data that is part of the pdf, as well as the pdf itself, is not persisted at any point outside of the Mendix app.
If data privacy is a concern for you, contact us for a docker-ized solution that you can deploy on your own infrastructure.
To administer rate limits (see below) templator stores the timestamp, the number of pages, project id and app url for each request.
Styling tips and gotchas
Most CSS styling is supported when generating PDF. However, there are some inconsistencies or strange behaviors when generating a PDF from HTML/CSS. An extended list of gotchas was compiled by Nathan at https://nathanfriend.io/2019/04/15/pdf-gotchas-with-headless-chrome.html
Rate limitations and timeouts
To promote fair use, templator sets rate, and time limits.
The rate and time limits are subject to change at any moment without notice.
Chrome version
Templator uses Chrome version 81 to generate the PDF.
Feedback
For feedback and questions reach out to me via the Mendix community Slack https://app.slack.com/client/TK3TS4MV0/DNLKSE7U6/user_profile/UKH7GPA1F