<-- Back

Document Templates do not support HTML

Issue

When generating PDFs from Rich Text content, users may encounter an error due to invalid XHTML structure. The error occurs because Document Templates strict XHTML compliance, whereas the Rich Text Editor may output standard HTML5, which allows self-closing tags (e.g., <img src="image.png"> instead of <img src="image.png" /> or <img src="image.png"></img>).

com.mendix.webui.WebUIException: Exception while executing runtime operation
at com.mendix.webui.actions.client.RuntimeOperationAction.apply(RuntimeOperationAction.scala:72)

Caused by: com.mendix.modules.microflowengine.MicroflowException: Error processing XHTML
at MyFirstModule.ACT_ExportTextToPDF (DocumentExport : 'Generate PDF (.pdf) document using template 'Document_template'')

Advanced stacktrace:
at com.mendix.modules.microflowengine.MicroflowUtil$.processException(MicroflowUtil.scala:73)

Caused by: com.mendix.systemwideinterfaces.MendixRuntimeException: Error processing XHTML
at com.mendix.documentexporter.focomponents.DynamicLabel$1.run(DynamicLabel.java:149)

Caused by: org.xml.sax.SAXParseException: The element type "img" must be terminated by the matching end-tag "".

Environment

Rich Text widget (all versions)

Cause

Document Templates use XHTML (a stricter XML-based version of HTML), which requires:

  • All tags to be properly closed (e.g., <img /> or <img></img>).
  • Attributes to be quoted (e.g., src="image.png").
  • No unclosed tags (e.g., <br> must be <br />).

The Rich Text Editor, however, generates HTML5, which is more lenient and does not enforce strict closing tags.

Solution/Workaround

To resolve the issue, two options are available

  1. Converting the HTML output from the Rich Text Editor into valid XHTML before passing it to the Document Template.
    • Either manually add the close image tag
    • Or use HTML To XHTML(community supported module)
  2. Use PDF Document Generation module

Internal information related

  • 230691, 241796

Additional information 

Mendix documentation: Dynamic Label (Document Template)

 

 

Have more questions? Submit a request

0 Comments

Article is closed for comments.

To provide feedback, please open a ticket here. Don't forget to include the article's URL along with the feedback you would like to provide.