Embed an image in a document through xhtml -solved

0
Thanks in advance for your help. I’m creating a downloadable word document based on domain data. Because of the limitations of the document template I’m doing this largely through xhtml embedded in the document template.  Everything works well until I try to embed an image. I tried the obvious way, which is the <img> tag. In my example it comes out like this:  <img src=”./file?guid=14073748835533001&changedDate=1621366228795&thumb=true&name=focus-group.png” /> But the xhtml throws an error at this point and doesn’t commit.  Is there a way to embed an image in the document template through xhtml? If so, please tell me how. Many thanks. -----------------Answered-------------------------- In the end I found an answer. I included the contents of the image as a base64 encoded string. <img src=”data:image/png,base64,(and then include the contents of the image) I was able to do this by calling the $Image/contents variable, and using the Community Commons library to encode this into a base64 string, using the Base64 Encode File java call.  I hoep this helps someone else struggling with this problem. 
asked
3 answers
1

In the end I found an answer. I included the contents of the image as a base64 encoded string. <img src=”data:image/png,base64,(and then include the contents of the image)

I was able to do this by calling the $Image/contents variable, and using the Community Commons library to encode this into a base64 string, using the Base64 Encode File java call. 

I hoep this helps someone else struggling with this problem. 

answered
0

HI David,

Where is the image located ? 
Is it stored in a enity in mendix ? if you know the GUID of the image enity you can put cutom java action to retrieve the Enitity object  and you can use a dynamic image veiwer in document template. 
Kindly accept the if this solution works for you.
 

answered
0

You could use my Word Exportermodule for this. It allows for adding images if added via the ckEditor widget. Do note this approach doesn’t use the Mendix document template, 

There is a demo app in which you could check your use case. 
 

Good luck!

answered