When loading in a DOCX with incorrect page numbers in the TOC, saving the document to DOCX and PDF results in incorrect page numbers in the TOC. The SaveOptions in the documentation say that UpdateFields is true by default, but I get a different result if it is called manually. If I manually add a call to UpdateFields after loading in the document, then the PDF comes out correct and the DOCX changes but is still wrong. I also tried passing in SaveOptions with UpdateFields set to true and that did the same as not providing SaveOptions. I tried this on Aspose.Words for .NET version 19.11 and 20.4. I got the same results from both.
While some of the earlier sections are wrong, such as 2.4.1, the easiest section to look at is the last section as it is the most off.
I used the following code and these are my input/output files: IncorrectPageNumbers2.zip (638.4 KB)
Document test = new Document("Incorrect_PageNumbers.DOCX"); test.Save("Incorrect_Aspose.DOCX"); test.Save("Incorrect_Aspose.PDF"); Document test2 = new Document("Incorrect_PageNumbers.DOCX"); test2.UpdateFields(); test2.Save("Incorrect_Aspose2.DOCX"); test2.Save("Correct_Aspose.PDF");