html2docx icon indicating copy to clipboard operation
html2docx copied to clipboard

<img src="data:image/png;base64,xxxx==>

Open Mustard404 opened this issue 3 years ago • 7 comments

Mustard404 avatar Apr 18 '21 09:04 Mustard404

Could you please provide some more information about this issue?

pqzx avatar May 04 '21 10:05 pqzx

Same issue here... in HTML - there is an easier way to have images - inline as base64

Another project pip html2docx solves this - in this file

More information on this at https://www.w3docs.com/snippets/html/how-to-display-base64-images-in-html.html

Essentially if your html file is self-contained - with images as inline base64 format - content is added as a string instead of an image.

bpasham avatar May 26 '21 14:05 bpasham

同样的问题... 在HTML中-有一种更简单的图像获取方法-与base64内联

另一个项目pip html2docx解决了这个问题-在此文件中

有关此的更多信息,请访问 https://www.w3docs.com/snippets/html/how-to-display-base64-images-in-html.html

本质上,如果您的html文件是独立的-图像采用内联base64格式-内容将作为字符串而不是图像添加。

thank you

Mustard404 avatar May 27 '21 08:05 Mustard404

I grabbed code from the file @bpasham suggested and tried to make it work here: https://github.com/abubelinha/html2docx/commit/530b4ed372d960b9a6e67843e8bea1037c1ba853

Looks like it works but I haven't tested it so much. There might be some issues in the original code, too. @abubelinha

abubelinha avatar Dec 08 '21 20:12 abubelinha

@abubelinha thank you so much for the modification. I can confirm it worked on my end!

MikeYuanMY avatar Feb 09 '22 19:02 MikeYuanMY

Hi there, does anyone have done a few tests to check if this modification behaves as intended ? @abubelinha would you mind doing a PR to the main codebase to be able to use it in the main code base ? :) Being able to generate documents with inline base64 images would definitely help me :)

almandin avatar Mar 08 '22 16:03 almandin

Sorry @almandin but I am not a git user by any means. I use github for reporting issues but have no idea about how to do a PR (I don't actually understand what it is). Maybe @pqzx can solve it.

For my solution, I just edited the code in the .py file installed by pip. It worked for a couple of images I tried. But as I linked above, the original code had an open issue.

Feel free to take it and try to do a PR yourself it you know how to do it.

abubelinha avatar Mar 08 '22 20:03 abubelinha