user26566721
user26566721

Reputation: 21

Transformation of xhtml to docx using docx4j doesn't scale down an image

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

Answers (0)

Related Questions