I don’t seem to be able to generate a proper index AND a table of content in the same document.
When I do the TOC is not correct.
In order to demonstrate that, I attach to the following a base document. If you load it with aspose, call updateFields and save it to a docx or a pdf, the TOC (which is bad) is unchanged.z.zip (30.6 KB)
The code to demonstrate is this:
Document doc = new Document("tocAndIndex.docx"); doc.updatePageLayout(); doc.updateFields(); doc.save("out.docx"); doc.save("out.pdf");
The TOC in all the documents (the source, generated with a complex java code) , out.docx and out.pdf all have very wrong page numbers.
I’m using Aspose word Java v 18.2 under Windows