Table of Content has wrong numbering on a document that contains revisions

Hello,

I’m using Aspose.Words for .NET (ver. 23.5.0)
I’m having the following issue when I try to generate the Table of Content on adocument that contains revisions.
Revised_document.docx (14.8 KB)

The numbering is wrong when I generate the TOC using Aspose.words
You can see the result here.
TOC_generated_by_Aspose.docx (15.4 KB)

For example:

  • the chapter “LOGGING” is located in the 4th page but in the TOC, it says 5th page.
  • the chapter "CONCLUSION " is located in the 11th page but in the TOC, it says 12th page.

To generate the Table of Content using Aspose.Words, i use the following line of code :

docBuilder.InsertTableOfContents("\\o \"1-3\" \\h \\z \\u");

I think the code generates the Table of Content using the “All markups” view and not the “Simple markup” view.

When I generate the Table of Content manually in Word, I obtain a table of content with right numbering.
You can see it here
TOC_generated_manually_in_Word.docx (18.8 KB)

Any suggestions ?
Best regards,

@Irchad You can use RevisionOptions to configure how revisions are taken in account upon building document layout. In your case you can use the following code:

Document doc = new Document(@"C:\Temp\in.docx");
doc.FirstSection.Body.PrependChild(new Paragraph(doc));
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertTableOfContents("\\o \"1-3\" \\h \\z \\u");
// Configure how revisions are rendered.
doc.LayoutOptions.RevisionOptions.ShowRevisionMarks = false;
doc.UpdateFields();
doc.Save(@"C:\Temp\out.docx");