We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

TOC behaving strangely in OpenOffice/LibreOffice

Hi,


I’m having some strange results using Aspose.Words to generete documents with a Table Of Contents.
Testing system:
  • Windows 7
  • Aspose 14.3
  • Office 2010
  • OpenOffice 3.4.1
  • LibreOffice 4.1.4.2
In the attachements you will find 3 documents, all identically generated with Aspose, only to a different save format (doc, docx and odt).
Opening the doc and docx file in Word works perfectly, everything is calculated correctly and the TOC can be recalculated without problems. Opening the different documents (doc, docx and odt) in OpenOffice or LibreOffice gives some strange results.

Opening the .doc file in LibreOffice (or OpenOffice) shows a highly reduced table of contents (see attachement: Word_vs_LibreOffice_TOC.png) and recalculating the TOC does not change anything, it remains like that.

Opening the .odt file in LibreOffice (of OpenOffice) shows the correct table of contents, but recalculating it removes the last lines in the TOC (see attachement: LibreOffice_Generated_vs_Recalced.png).

The docx file on the otherhand seems to behaving nicely in both Word and LibreOffice (or OpenOffice). Opening the document in both gives the full table of contents and recalculating them gives the expected result with the TOC being recalculated correctly (see attachement: DOCX_Word_vs_LibreOffice_TOC.png).

These files are all generated from the attached source file (3P_BE_NL_Bestek.doc) by filling in the mergefield with a bunch of custom code (so no automatic mailmerge).

Hi Nick,


Thanks for your inquiry. We are working over your query and will get back to you soon.

Best regards,

Hi Nick,


Thanks for being patient.
Nick:
Opening the .odt file in LibreOffice (of OpenOffice) shows the correct table of contents, but recalculating it removes the last lines in the TOC (see attachement: LibreOffice_Generated_vs_Recalced.png).
In this case, Aspose.Words mimics the behavior of Microsoft Word. To confirm this, please open “3P_BE_NL_Bestek.doc” with Microsoft Word 2013 and then do the following steps:

  1. Right-click on the Table of Contents
  2. From the right-click menu, click Update Field. Update Table of Contents dialog box appears.
  3. Select the option Update Entire Table. Click OK.
  4. Save As this .doc to .odt format. (I have attached a similar .odt here for your reference: out-msw-2013.odt)

Now, open this .odt with OpenOffice Writer v3.4 and update Index/Table, you’ll notice it also removes those entries from the end of TOC even from Microsoft Word generated .odt. So, this is not a bug in Aspose.Words as it correctly mimics the behavior of Microsoft Word.
Nick:
Opening the .doc file in LibreOffice (or OpenOffice) shows a highly reduced table of contents (see attachement: Word_vs_LibreOffice_TOC.png) and recalculating the TOC does not change anything, it remains like that.
This is also not a problem in Aspose.Words but a glitch in old OpenOffice Writer v3.4 which is now partially resolved in OpenOffice Writer v4.0. To confirm this, please repeat the above 4 steps and generate a .doc file using Microsoft Word 2013. I have also attached a .doc file here for your reference (out-msw-2013.doc). Open this .doc with latest OpenOffice Writer application. You’ll notice all entries of TOC are correctly listed. However, re-calculating them removes a few entries from the end of TOC as is the case with first scenario.

If we can help you with anything else, please feel free to ask.

Best regards,

Hi Awais,


Thank you for the thorough explanation.
It seems odd to me though for Aspose to save the .odt file in such a way that it performs worse then when it is saved as docx and converted to odt?

Is this merely because the implementation of .docx is better supported in OpenOffice in contradiction to .doc?
Might be usefull to be able to choose between .doc or .docx compatibility mode for .odt files? If this is at all possible of course.

Hi Nick,


Thanks for your inquiry. Aspose.Words exports document to .odt format as per ODT specifications. Not all features of .docx are supported by .doc and not all features of .doc are supported by .odt format. It seems OpenOffice is unable to populate TOC because it is natively designed to work with ODT format. OpenOffice couldn’t even populate TOC in your original “3P_BE_NL_Bestek.doc” document.

Besides this, you may want to use OdtSaveOptions.IsStrictSchema11 property to specify whether export should correspond to ODT specification 1.1 strictly. OO 3.0 displays files correctly when they contain elements and attributes of ODT 1.2. Use “false” for this purpose, or “true” for strict conformity of specification 1.1.

Best regards,