I'm trying to dynamically generate a word document on the client for a report.
I create a HTML string in the format:
<html xmlns:office="urn:schemas-microsoft-com:office:office" xmlns:word="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<xml>
<word:WordDocument>
<word:View>Print</word:View>
<word:Zoom>90</word:Zoom>
<word:DoNotOptimizeForBrowser/>
</word:WordDocument>
</xml>
<style>Some CSS</style>
</head>
<body>
Some HTML
</body>
And then base64 convert the HTML string and set the download attribute on an a to be "data:text/html,base64EncodedText"
This all works fine except that the images do not work.
I've tried: img src="https://hostname/imagepath", img src="data:image/png;base64encodeduri" and started trying to use a VML but have had no luck (the encoded srcs open fine when using them as a URL in the browser).
Can anyone help? What is the best way to get images into a word document?
If possible I'd like to avoid using a library, I've looked at docx.js but can't use it because of the licensing (and that there are no examples for it...).
Thanks