Generate .docx from HTML with Base64 images with docx4j

本小妞迷上赌 提交于 2019-12-06 03:52:46

The issue is with Word rather than docx4j.

Microsoft Word doesn't support embedded data when it comes to importing XHTML. If you save your html string in a separate HTML file and try to open it in Word, you will see that it brings in the file with its formatting present, but the images are broken.

A better solution would be for your code to import the XHTML "natively" (rather than as an AltChunk: @JasonPlutext provides a link for doing that in his comment), and then bring the images in using custom code: i.e. extract and decode the Base64 content so you have binary data, and then pull that into Word using the docx4j API (BinaryPartAbstractImage.createImagePart() or similar).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!