Hi Hafeez,
I have tried to update TOC of a document with the code snippet you have posted above
Document doc = new Document("D:\\Temp\\in.docx");
foreach (Field field in doc.Range.Fields)
{
if (field.Type == FieldType.FieldTOC)
{
FieldToc toc = (FieldToc)field;
toc.UpdatePageNumbers();
}
}
doc.Save("D:\\Temp\\18.7.docx");
But in the final generated document still the TOC page numbers not getting updated.
I am attaching the link for the word document for which i have tried this code.
https://easyupload.io/0w2m5c
In the document you can see the mismatch of page numbers i.e.:
6.2 Toxicity Management is on page number 28 but in TOC it is showing as page number 27.
Similarly the problem with the following topic numbers and the page references for others.
Your solution on this will be really helpful for me.
Regards,
Uddeshya Pratik