guigrpa / docx-templates

Template-based docx report creation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using base64 as src for <img> inside altChunk

Darwin1337 opened this issue · comments

When using base64 as source for the img tag inside the +++HTML +++, the result image will have its lower half completely distorted.
image

I've read this is because of the way altchunk handles images. I also read that the solution is to use mht content instead of html.

My use case is: I have an array of HTML strings (with paragraphs and images mostly). The image links are protected with a JWT cookie and I can't seem to append it to word's requests for those images. So I just fetch the image via JS (where I can append the cookie) and feed the base64 raw data to the src attribute. Am I missing an easy solution or is b64 and mht the way to go?