PDF Document Generation
Content Type: Module
Categories: Utility,Import/Export
Overview
The Document Generation module allows you to generate pixel-perfect PDF documents based on regular pages in your app. Make use of the full capabilities of the page editor, including the use of snippets, text templates, conditional visibility based on expressions, dynamic classes, etc. Add any existing web widget from the marketplace to your documents, or create your own.
Documentation
Please see Document Generation in the Mendix documentation for details.
Releases
Version: 1.2.0
Framework Version: 9.18.0
Release Notes: - We included a migration file for the Java dependencies for Studio Pro 10 compatibility.
Version: 1.1.1
Framework Version: 9.18.0
Release Notes: - We fixed incorrect module version logging.
- We fixed a consistency error of an unsupported design property when `ExampleDocument` page was included in the project.
- We fixed an issue when generating a document returned a timeout if you also configured the Mendix Runtime custom setting `ApplicationRootURL` to a custom domain.
Version: 1.1.0
Framework Version: 9.18.0
Release Notes: Note: This GA release contains breaking changes when migrating from the public beta version (v1.0.0).
New Features:
- We now apply the same styling that is used in your web browser when exporting a page to PDF, instead of print-specific styling. This means that your PDF documents are even closer to what you see in the browser or when using ‘Design mode’ in Studio Pro.
- The class `document-generation-body-injected` is injected by the document generation service to the body element of your page. You can use this class instead of `@media print` if you want to re-use the same page for web and PDF documents, but apply some specific styles to the PDF document only.
- We introduced two new design properties to the `Container widget` to help structure your documents:
- Add page break: This design property enables you to force a page break before or after the specific container widget.
- Avoid break inside: This design property allows you to prevent page breaks within a specific container. This can be useful to keep widgets grouped together on the same page.
- We introduced the `$document-background-color` theme variable to configure the default background color of your PDF documents.
- Note: When using Studio Pro 9.24.4 or lower, the background color that is set using this variable is not previewed correctly when using ‘Design mode’.
Improvements:
- We now use the time zone of the user that is passed in the `Generate as user` property for the localization of dates and times. If no time zone is configured for this user, it will use the default time zone as set in the App Settings. If the default time zone is not set, then the dates and times are displayed using UTC.
- We have increased the maximum file size of a PDF from 10 MB to 25 MB per document. If your document exceeds this limit, the action will result in a timeout.
- We no longer require Create and Write access rights for the user that is set for the ‘Generate as user’ property of the microflow action.
- Note that setting the microflow property ‘Apply entity access’ to ‘Yes’ does not have any effect here. Regardless of the setting, the action does not require Create or Write access rights for the `FileDocument` object that gets created.
- We removed the dependency on the FieldSet widget.
- We removed the RedirectLayout from the module.
- We removed the constants `UseCustomApplicationUrl` and `CustomApplicationUrl`. The document generation service now uses:
- When running locally from Studio Pro: The Application Root URL as configured in the App Settings.
- When running in the Mendix Cloud: The App URL as registered during the app environment registration.
Breaking changes:
- As we now apply the same styling that is used in your web browser instead of print-specific styling, you can no longer use the `@media print` media query to apply specific styles to the PDF document only. Use the `document-generation-body-injected` or `document-content` classes instead.
- We have improved the mechanism that determines when the page has finished loading. We now wait until there are no more pending network requests.
- Note: widgets or add-ons (for example a script in your `index.html`) that perform long polling network requests, are no longer supported.
- We renamed the `DocumentLayout` layout to `DocumentGeneration_Default`.
- When migrating from the public beta version, update the layout for all pages that are currently using `DocumentLayout`. Do not forget to set the design property `Enable PDF export` to ‘Yes’ for each page.
- The use of this layout is no longer required. You can now use any layout of layout type `Responsive`, or create your own layout, as long as the layout does not include a scroll container. Layouts that do include a scroll container, such as `Atlas_Default`, will result in incomplete content.
- We introduced a new design property `Enable PDF export`. Set this property to ‘Yes’ for any page that you want to export as a PDF using the module.
- Note: setting this property is required. When migrating from the public beta version, do not forget to set this property for all pages that previously used the `DocumentLayout` layout.
- We renamed the widgets that are included in the module. When migrating from the public beta version, remove the previous versions of the widgets by deleting the files below from the `widgets` directory of your app, and update all affected pages to use the new widgets.
- Delete the file `mendix.DocGenRedirect.mpk` from the `widgets` directory
- Delete the file `mendix.PageBreak.mpk` from the `widgets` directory
- We renamed the theme variable `$default-margin` to `$document-section-padding`. To set the page margin of your documents, we recommend to set this using the `@page` rule in your stylesheet.
- We renamed the `remove-margin` classes in the module stylesheet to `remove-padding`. If you are using one of those classes in your documents, update them accordingly.
Fixes:
- We now support apps that include a Responsive Web Offline navigation profile. (Ticket #190165)
- We removed incorrect Dutch translations from the registration snippet.
Version: 1.0.0
Framework Version: 9.18.0
Release Notes: - Generate pixel-perfect PDF documents based on regular pages in your app.
- Make use of the full capabilities of the page editor, including the use of snippets, text templates, conditional visibility based on expressions, dynamic classes, etc.
- Support adding any existing web widget to your document, or creating your own widgets and using them in your documents.
- Use “Instant Update” during local development, which allows you to see changes to your documents immediately without having to do a full restart of your app.
- Generate documents using a synchronous or asynchronous approach. In the asynchronous action, the result object is available instantly, the content is added at a later stage.