Convert ODT File to Word DOCX Document using Java | Preserve Page Layout, Footer picture & X-Y Position of Chart

When converting an ODT to DOCX, the layout of the ODT is not preserved properly.
The page layout is different in the translated document.
I’ve had this problem in the past, however I was informed that the issue had been resolved.

Using “aspose-words-20.8.0-jdk17.jar”.

Code Below:
com.aspose.words.Document doc = new com.aspose.words.Document(inputPath);
doc.save(outputPath, com.aspose.words.SaveFormat.DOCX);

Before/after files attached:
Defect.zip (102.2 KB)

@simon.wiseman,

The issues even occur when doing a ODT to ODT ‘Save As’ operation by using latest 20.11 version of Aspose.Words for Java. And currently, same is the case with ODT to DOCX conversion. We have observed the following issues on our end and logged them in our issue tracking system:

  • WORDSNET-21422: Aspose.Words generated DOCX file currently shows 4 pages because it incorrectly spans content of first page of ODT to two pages.

  • WORDSNET-21423: ODT to DOCX - Footer picture not showing at the very bottom edge of pages

  • WORDSNET-21424: Charts from second and third pages lose their x-y position in generated DOCX. Moreover, there is an issue with the positioning of last two text paragraphs on last page.

We will further look into the details of these problems and will keep you updated on the status of corrections. We apologize for your inconvenience.

@simon.wiseman,

We need a bit more information from your end; please tell what software application(s) (and their version number) do you use to create/view ODT and DOCX file formats. Do you use MS Word or Libre/Open Office?

The ODT was created using Google Docs and the DOCX was created using Aspose Translation using the code I attached in my previous comment.

@simon.wiseman,

We have logged these details in our issue tracking system and will keep you posted here on any further updates.

@simon.wiseman,

It is to inform you that we have completed the analysis of WORDSNET-21423. Different editors render this document differently. For example, this is how the documents look like in Open Office and MS Word.

The reason for different display is in different interpretation of the footer code by OpenOffice Writer and MS Word editors.

<style:style style:family="graphic" style:name="a3" style:parent-style-name="Graphics">
    <style:graphic-properties fo:border="none" fo:background-color="transparent" style:wrap="parallel" style:wrap-contour="false" fo:clip="rect(0in, 0in, 0in, 0in)" 
        style:horizontal-rel="page-content" 
        style:vertical-rel="paragraph" 
        style:horizontal-pos="from-left" style:vertical-pos="from-top"/>
</style:style>
...
<draw:frame draw:z-index="251660288" draw:style-name="a3" draw:name="image11.png" 
    style:horizontal-rel="page-content" 
    style:vertical-rel="paragraph"
    text:anchor-type="paragraph" 
    svg:x="-1.00521in" 
    svg:y="0.19792in" 
    svg:width="8.50521in" 
    svg:height="1.1598in" 
    style:rel-width="scale" 
    style:rel-height="scale">
    <draw:image xlink:href="media/image2.png" 
        xlink:type="simple" 
        xlink:show="embed" 
        xlink:actuate="onLoad"/>
    <svg:desc>footer graphic</svg:desc>
</draw:frame>

OpenOffice ignores the image exact coordinates in the footer when displaying the document, focusing on the anchor snapping to the paragraph.

style:horizontal-rel="page-content" 
style:vertical-rel="paragraph" 
...
text:anchor-type="paragraph" 
style:rel-width="scale" 
style:rel-height="scale">

MS Word ignores anchor snapping, focusing on the image exact coordinates when displaying the document.

svg:x="-1.00521in" 
svg:y="0.19792in" 
svg:width="8.50521in" 
svg:height="1.1598in" 

During resaving OpenOffice retains full formatting, the exact coordinates and the anchor snapping. MS Word only saves the exact coordinates, resetting the anchor snapping to its default value. Aspose.Words exactly mimics MS Word’s behavior in this case. A document saved from ODT to DOCX by Aspose.Words does not differ from the document saved from ODT to DOCX by MS Word.

We can try implementing OpenOffice display algorithm, but in this case the result will be different from that of MS Word.

Can you please also provide your expected document showing the desired output here for our reference?

I can see that Aspose is correctly mimicking Words behaviour.
If at all possible I would like to translate from ODT to DOCX and preserve the page layout, perhaps with a save option that overrides the normal behaviour and implements the OpenOffice display algorithm instead?

@simon.wiseman,

We have logged these details in our issue tracking system and will keep you posted here on any further updates.

Amazing, thank you.

The issues you have found earlier (filed as WORDSNET-21422) have been fixed in this Aspose.Words for Java 24.2 update.