guigrpa / docx-templates

Template-based docx report creation
MIT License
882 stars 145 forks source link

Using base64 as src for <img> inside altChunk #338

Closed Darwin1337 closed 6 months ago

Darwin1337 commented 9 months ago

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?

jjhbw commented 8 months ago

That's really weird, but I don't think this is a docx-templates issue, but a Word issue. I'll leave this open for now in case others have an idea.

Darwin1337 commented 6 months ago

Unlikely this will be ever reproduced as this was a bug on my end.

jjhbw commented 6 months ago

@Darwin1337 Ah ok, good to know. Thank you for taking the time to close this issue 👍