Issue
When generating a PDF from a Document Template with Render XHTML set to Yes, the following error occurs if the content contains a numbered or bulleted list created with the Rich Text widget (for example, Rich Text widget v4.12):
Fatal error on create of PDF: Invalid property encountered on "fo:list-block": list-style-type (See position :-1)
The PDF generation fails and no document is created.
Environment
Studio Pro (all versions)
Cause
The Rich Text widget generates HTML5 output, while the Document Template PDF generation engine requires XHTML when Render XHTML is enabled.
By default, the Rich Text widget includes inline styling for list elements. When Policy 5 in the XSS Policy configuration is set to STYLES, the generated HTML contains the list-style-type style attribute.
During PDF generation, the document engine converts the XHTML into XSL Formatting Objects (XSL-FO). The XSL-FO processor does not support the list-style-type attribute on fo:list-block, and causes the document generation to fail with a fatal validation error.
Solution/Workaround
Workaround 1: Sanitize the Rich Text content before generating the PDF and remove the unsupported inline style generated by the Rich Text widget.
- Add the XSSSanitize action found in the Community Commons to the microflow before the document generation activity.
- Pass the sanitized HTML to the Document Template.
- Generate the PDF.
The sanitization process converts the HTML into XHTML that is compatible with the Document Template PDF generation engine.
Workaround 2: Remove the STYLES policy to prevent the Rich Text widget from adding the unsupported list-style-type attribute and allow the PDF to be generated.
- Open the Rich Text widget configuration in Mendix Studio Pro.
- Go to the XSS Policy tab in the widget configuration settings.
- Locate Policy 5.
- Clear the value STYLES.
- Run the application.
- Generate the PDF again.
Internal information related
- 281762,236523,238337,255960
- CJZ85RLTA/p1734438299059299
Additional information
Mendix documentation:
0 Comments