Templator - Document (PDF) and report generation alternative

Content Type: Module
Categories:

Overview

Templator is a Mendix module that lets developers generate PDF files using standard Mendix components. Because normal pages are used to generate the documents all styling (rounded corners ✅) and all built-in & app store widgets (charts ✅) are supported out of the box. This makes templator the perfect tool for generating invoices and reports. Finally, your users will be able to get the same experience regardless if they are looking at your app or a PDF file generated from your app. Your developers will love it too because they can reuse existing pages, widgets, and styling, and only need to build standard pages which thanks to Mendix, is super fast and easy.

Documentation

null
Demo urlhttps://templator-demo-sandbox.mxapps.io

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

  1. 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.

  2. Declare a microflow that opens the page from step1.

  3. 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

Releases

Version: 1.5.0
Framework Version: 7.23.0
Release Notes: Fixed bug where object was empty in ShowPage microflow
Version: 1.4.0
Framework Version: 7.23.0
Release Notes: * increased stability * automatic retries in case of recoverable errors * longer time limits * removed APIKey constant
Version: 1.3.0
Framework Version: 7.23.0
Release Notes: - Removed watermark for all users - Improved performance and error messages
Version: 1.2.0
Framework Version: 7.23.0
Release Notes: - added option to disable all bootstrap print styling (Thanks Gorjan for the feedback) - update service to generate colors exactly - added constant for function key to more easily support on-premise docker deployment
Version: 1.1.0
Framework Version: 7.23.0
Release Notes: - added asymmetric encryption - all sensitive data sent from the module to the service is now encrypted. Only the service has the secret key needed to decrypt the data. This prevents sending sensitive data to a third party by accident, for example, you misconfigure the *ServiceEndpoint.* - added options to hide Mendix dialogs and validation messages, true by default