When converting from docx to html you may specify the output path for any images
org.docx4j.Docx4J.toHTML(wordMLPackage, imageDirPath, imageTargetUri, fos2);
and the resulting html document references images via files:
<img height="22" id="rId7" src="..cc6bcedf-2770-45ad-8e81-610bbd8746ceimage1.png" width="42">
Instead I would like the converter to embed the files as base64. Is this possible?
You do not need a custom
ConversionImageHandler
to achieve this. You can simply set imageDirPath to an empty string and the images will be embeddedThis occurs because
org.docx4j.model.images.AbstractConversionImageHandler
(from whichHTMLConversionImageHandler
derives) already handles this case for you .