HOW TO GENERATE A PDF WITH DOCUMENT TEMPLATE | MENDIX 8

0
Hello Team,I am new to Mendix and working with Mendix Studio Pro 8.18.27 (old version, limited features). I need help to generate a PDF comparison report using a Document Template.
asked
3 answers
1

Hello,

Even though you are using Mendix Studio Pro 8.18.27, you can generate a PDF comparison report using a Document Template, but with a few limitations because it is an older version.

Here is the recommended approach:

  1. Create a Persistable Entity
    • Store the data you want to compare (for example: Old Value vs New Value, Item A vs Item B).
    • Document Templates work only with persistable entities.
  2. Design the Document Template
    • Create a new Document Template.
    • Use a Table layout to display comparison columns (e.g., Field Name | Value 1 | Value 2).
    • Bind the template to the comparison entity.
  3. Prepare Data Using a Microflow
    • Use a microflow to:
      • Retrieve both records that need to be compared.
      • Populate the comparison entity with calculated differences.
      • Commit the comparison object.
  4. Generate the PDF
    • In the same microflow, use “Generate document” action.
    • Select the Document Template and output format as PDF.
    • Store or download the generated file.

Limitations in Studio Pro 8.18.27

  • No advanced styling like modern CSS
  • No conditional visibility inside Document Templates
  • Comparison logic must be handled in microflows, not directly in the template

If advanced formatting or dynamic comparison logic is required, upgrading to a newer Mendix version (9 or 10) is recommended.

Hope this helps.

Thanks!


answered
1

I would recommend using a Document Template together with a microflow, as this is the most reliable approach in Mendix 8.18.27.


A good practice is to first prepare the comparison data in a simple helper structure, where each row represents one item being compared (for example, field name, old value, and new value). This keeps the logic clear and makes the document easy to render.


Then, in the microflow, generate this data and pass it to a Document Template that displays the comparison in a table format. Finally, use the standard Generate document and Download file actions to produce and deliver the PDF. This approach is straightforward, well supported in older Mendix versions, and easy to maintain.


answered
0

Hello,

You can generate dynamic PDF reports in Mendix using Document Templates, and the approach is general enough to apply to any use case where structured comparison or reporting is needed.

Recommended approach:

  • Create a Persistable Entity Generalize it from System.FileDocument so the PDF can be stored. Add attributes like ReportName and associations to the records you want to compare (e.g., old vs new).
  • Design the Document Template Use tables to display side‑by‑side values. Add clear section headers for readability.
  • Prepare Data with a Microflow Retrieve the records to be compared, populate the comparison entity, and commit it. In the same microflow, use the Generate Document action, bind it to the template, and set a dynamic file name using an expression such as:
  • Code
$Entity/name + ' Report ' 
  • This ensures each file has a unique, meaningful name.
  • Generate and Download the PDF The microflow outputs the PDF, which can be stored or downloaded.

Limitations in older Mendix versions:

  • Styling options are basic (no advanced CSS).
  • Conditional visibility is not supported inside Document Templates.
  • Comparison logic must be handled in microflows, not directly in the template.

This method provides a reusable way to produce professional, audit‑friendly reports with dynamic names, and can be adapted for any scenario where comparisons or structured documentation are required.

Thanks!


answered