Reputation: 21
I am converting xhtml to docx using doc4j. I would like to produce docx from simple xhtml, which includes an image. The relevant part of the input is:
<p> and a big picture with css style width:100%;:</p>
<img style="width:100%;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABm0AAAExCAYAA..." />
The image has significant width thus the width:100% setting to accommodate it.
My code is as follows:
String xhtmlText = addDoctype(pXHTML);
WordprocessingMLPackage wordMLPackageXHTML = WordprocessingMLPackage.createPackage();
XHTMLImporterImpl XHTMLImporter = new XHTMLImporterImpl(wordMLPackageXHTML); wordMLPackageXHTML.getMainDocumentPart().getContent().addAll(XHTMLImporter.convert(xhtmlText, null));
Save saveToZip = new Save(wordMLPackageXHTML);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
saveToZip.save(byteArrayOutputStream);
In the resulting docx file, the big image is not scaled down according to the width:100%
setting but is cut off from the right side. How can the picture be displayed completely?
Upvotes: 1
Views: 9