I am having a problem with image size in docx4j-ImportXHTML (the flying saucer fork). It seems to not handle image size from style the same. I chose docx4j because the library has a PDF conterpart (flying saucer) that can use the same html template to render either. For the most part, it does work but for images it seems to ignore the styles for size causing the images to not scale and be pushed past the edge of the document. The flying saucer (PDF) version doesnt do this just docx4j-ImportXHTML.
I have attached a project that has a simple html file (<20 lines) and a unit test that renders that file as both pdf and docx, using flying saucer and docx4j-ImportXHTML respectively. You can review the output documents in the target directory for comparison. The PDF appears right while the docx file appears to ignore my image sizes. BTW I am using inches and cm as the image size units but it does not seem to matter if I convert them to pixels either unless I assume a ridiculous DPI (like 600!) which breaks the PDF rendering.
-Matt
related: docx-java-f6/image-size-differs-when-pdf-and-docx-are-generated-t2367.html