Combination of Rich Text Modul with dynamic label widget in document template and PDF Export does not work.

0
Dear Community,    i have the requirement from my customer / users side to have an questionnaire with an input element allowing copying text and images from the clipboard. At the end there should be a report generated in PDF.    First of all it looked very easy and good by using the combination of the rich text marketplace module of mendix  in combination with a dynamic label widget of the document template and sending it to an pdf creator.     When i did it the first time it worked very good. I inserted a text and and image from the clipboard to the rich text editor and it was present at the PDF export based on the document template.   When i clicked the second time at the generate report button i got an error message that i should contact the administrator.    Long time and a lot of trials later i figured out the following:   At the rich text editor i have to deactivate sanitize content otherwise the picture is gone. I show in parallel the string variable with a text area element and even if i configure on change or on press key the content is not saved or at least displayed in the text area. Only when i change to another tab saving happens but sometimes with or without the picture XHTML code.  Sometimes the XHTML code is enlarged with “&nbsp” even when i didn´t do a backspace and then it runs into the failure with the message “contact your administrator”. When i remove this in the string variable it works again.   Has someone had similar requirements and / or is facing the same behaviour of the rich text module and the dynamic label widget? Every help would be great because im running out of ideas.    In my opinion one problem is the saving issue that the content in the rich text editor and the string variable is not the same and the second issue is that the rich text editor generates sometimes the entry &nbsp which can not be handled by the dynamic label.  
asked
2 answers
0

Hi Markus,

 

A late answer to your question, but I believe that the solution for problem 3 can be found in the following forum post: https://forum.mendix.com/link/space/studio-pro/questions/114302.

 

Cheers,

Jeffrey 

answered
0

 

I found a userlib --> commons-text-1.10.0 here --> https://commons.apache.org/proper/commons-text/download_text.cgi

Downlaoded the jar file and inserted it in my user lib. Then I created a java action that I use to unescape the HTML -->

// BEGIN USER CODE

return StringEscapeUtils.unescapeHtml4(this.InputHTML_Unescaped);

// END USER CODE

where the static class is imported like this in the upperside of the code -->

import org.apache.commons.text.StringEscapeUtils;

 

 

answered
0

Hi Guys,

 

thank you very much for your feedback and help. 

 

I have followed the tips and tried something but found out something which I didn´t expect, therefore I want to give you feedback from my side:

 

First I replaced the critical symbol (in my case  ) by its Unicode value like written by Michael Hero: replaceAll($HTMLToChange,' ',' ') and it worked. 

 

With a bad feeling in the background if some other symbols and characters could make trouble I implemented the usage of the unescapeHTML4 routine like suggested.

 

The   problem was also solved but I got a lot of other problems for example with this text:

 

Mustermann, Max (R&D) 
<max.mueller@siemens.com>

 

it was converted into:

 

Mustermann, Max (R&amp;D) 
&lt;max.mustermann@siemens.com&gt;

 

which was originally working fine with the PDF converter but after using the unescapeHTML4 routine it was converted to:

 

Mueller, Max (R&D)

This leads to an error because the compiler expected an command because of &…

 

 <max.mustermann@siemens.com>

This lead also to an error because the compiler was thinking this is an start tag of HTML.

 

Therefore now I switched back to an replacement of critical value manually.

 

Only for your information that escapeHTML is not really solving this problem. 

 

answered
0

Hi Guys,

 

thank you very much for your feedback and help. 

 

I have followed the tips and tried something but found out something which I didn´t expect, therefore I want to give you feedback from my side:

 

First I replaced the critical symbol (in my case &nbsp;) by its Unicode value like written by Michael Hero: replaceAll($HTMLToChange,'&nbsp;','&#160;') and it worked. 

 

With a bad feeling in the background if some other symbols and characters could make trouble I implemented the usage of the unescapeHTML4 routine like suggested.

 

The &nbsp; problem was also solved but I got a lot of other problems for example with this text:

 

Mustermann, Max (R&D) 
<max.mueller@siemens.com>

 

it was converted into:

 

Mustermann, Max (R&amp;D) 
&lt;max.mustermann@siemens.com&gt;

 

which was originally working fine with the PDF converter but after using the unescapeHTML4 routine it was converted to:

 

Mueller, Max (R&D)

This leads to an error because the compiler expected an command because of &…

 

 <max.mustermann@siemens.com>

This lead also to an error because the compiler was thinking this is an start tag of HTML.

 

Therefore now I switched back to an replacement of critical value manually.

 

Only for your information that escapeHTML is not really solving this problem. 

 

answered
0

Hi Guys,

 

thank you very much for your feedback and help. 

 

I have followed the tips and tried something but found out something which I didn´t expect, therefore I want to give you feedback from my side:

 

First I replaced the critical symbol (in my case &nbsp;) by its Unicode value like written by Michael Hero: replaceAll($HTMLToChange,'&nbsp;','&#160;') and it worked. 

 

With a bad feeling in the background if some other symbols and characters could make trouble I implemented the usage of the unescapeHTML4 routine like suggested.

 

The &nbsp; problem was also solved but I got a lot of other problems for example with this text:

 

Mustermann, Max (R&D) 
<max.mueller@siemens.com>

 

it was converted into:

 

Mustermann, Max (R&amp;D) 
&lt;max.mustermann@siemens.com&gt;

 

which was originally working fine with the PDF converter but after using the unescapeHTML4 routine it was converted to:

 

Mueller, Max (R&D)

This leads to an error because the compiler expected an command because of &…

 

 <max.mustermann@siemens.com>

This lead also to an error because the compiler was thinking this is an start tag of HTML.

 

Therefore now I switched back to an replacement of critical value manually.

 

Only for your information that escapeHTML is not really solving this problem. 

 

Markus

 

answered