Incorrect page number - Word document

Hi,
I’m facing with a problem when building a TOC (table of contents). I have about 20 .docx files. After I merged these words into the one destination file. The destination file has 70 pages and the page number showed correctly in the footer section.
I tried to build the TOC: get the page number basing on the bookmark on the pages that we want to get the page number.
And the numbers are returned wrongly. For example, it returned 36 for the page 35, it returned 92 for the page 70…
I’m not sure if this is an issue of ASPOSE word component or not.
I see one the similar topic related to PageCount and it also returns wrong number. Not sure this issue was fixed or not.
https://forum.aspose.com/t/65456
Can you please take a look on this problem?
Thanks,

Hi,

Thanks for your inquiry. Please call Document.UpdateFields method before saving your final document as shown below. Hope this solve your problem.

Document doc1 = new Document(MyDir + "input1.docx");
Document doc2 = new Document(MyDir + "input2.docx");
doc1.AppendDocument(doc2, ImportFormatMode.KeepSourceFormatting);
doc1.UpdateFields();
doc1.Save(MyDir + "AsposeOut.docx");

I suggest you to read following documentation links for your kind reference. Please let us know if you have any more queries.
https://docs.aspose.com/words/java/update-field/