plutext / docx4j-ImportXHTML

Converts XHTML to OpenXML WordML (docx) using docx4j
136 stars 125 forks source link

Units in CSS are not correct in docx (cm, mm, in) #68

Open achimmihca opened 3 years ago

achimmihca commented 3 years ago

Consider the following table, where the cell should have 10cm width:

<table>
    <tr>
        <td style="width: 10cm; background-color: #ff0000">1</td>
    </tr>
</table>

In the resulting docx, the cell has about 14cm width.

The size is consistent with other units. So "100mm" will also give this result. The width for "1in" seems also not correct in the docx file.

I guess there is a general issue with the transformation from CSS-unit to docx-unit.

docx4j has UnitsOfMeasurement.java which might be a good starting point for finding the correct calculation.

isedoykin commented 2 years ago

Any news for this? It seems units are not correct for images as well. For example, style for images: height: 100mm; width: 100mm; In the resulting docx, the image has about 170mm width and height.

What is the transformation from CSS-unit to docx-unit in docx4j used?