Update fields does not generate ToC correctly

Hello. I’m having an issue. When I use UpdateFields(), the ToC does not gerates correctly. But if I update manually, there is no problem. I attached a template with the issue. Thank you

ToC test.docx (58.2 KB)

@ruben.manjarrez.tr Unfortunately, I cannot reproduce the problem on my side using the latest 24.6 version of Aspose.Words and the following simple code:

Document doc = new Document(@"C:\Temp\in.docx");
doc.UpdateFields();
doc.Save(@"C:\Temp\out.docx");

The generated TOC looks the same as TOC generated by MS Word. Could you please attach your output document here for testing?

Hi. I attached the resulting document after the UpdateFileds. As you can notice, S2 and S3 in the ToC are one page before form they were supposed to be. Thank you for your help in advance.

ToC test.docx (49.8 KB)

@ruben.manjarrez.tr Unfortunately, it still can’t be reproduced. Could you please share more information about the processing of the document before updating fields? Maybe there is some font issues, that cause problems with the pages.