Resizing of base64 images in rich text when used in document generation (PDF)
We are generating reports in our application with a document template that receives part of the document from a rich text input. We are using the CKEditor widget to capture the rich text. Sometimes, the rich text input includes a base64 image, which I can resize in the editor, and have confirmed that the style is applied, but when passed to the document template the original size of the image is used, and sometimes is too large for the document, and therefore is cut off on the right side. When viewing the rich text in the CKEditor viewer, it is resized appropriately per the styling, so I know the style attribute is correct. I know that the string attribute that is passed to the document template contains the styling by using a breakpoint, but is ignored when the document generator interprets the XHTML. Is there another way to apply styling to the <img> tag within the XHTML, or some way to style it in the document template so that images that are too large are not cut off?
I’ve run into similar issues where the size of the image was ignored by the document template. In our case, it had to do with incorrect formatting of the style element. There is a difference how the rich text editor and CKEditor set the styling properties.
Mendix has this fixed with version 2.4.4 of CKEditor which solved the problem for us by adding a styling option to the widget.
We still experience many other styling issues with the document template. Have a look at “Word document Merge 4 Mendix’ as a much better alternative for Document Templates: https://www.appronto.nl/modules/word-merge-module