Issue while writing TOC to the document


My requirement is to read a document from a location and save it to other location and read the content of the document and write TOC to the document.

But the final document we have problem in building TOC with correct navigation.

Please resolve the issue. Please find the sample application as an attachment to this post.

Please run the application and u can find the document saved and open the document and try to navigate from TOC.

Please update ASAP.

Hi Srini,

Thanks for your inquiry. Moving the line “TempDoc1.UpdateFields();” to just before the save method will resolve this issue.

    TempDoc1.Save(dataDir + "\\FinalDoc.docx", SaveFormat.Docx);
catch (Exception ex)
    throw ex;

Hope, this helps.

PS: I have also attached final document which is generated using Aspose.Words for .NET 16.2.0 here for your reference.

Best regards,