We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to add the hyperlink for an existing table of content in the document

How to add the hyperlink for an existing table of content in the document. Kindly help me asap.
Please find the below input and expected word document.
Expected_Table of Contents.docx (29.1 KB)
Input_Table of Contents12.docx (28.9 KB)

@Manasahr You should set FieldToc.InsertHyperlinks and FieldToc.HideInWebLayout properties to get the desired output. For example see the following code:

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

doc.Range.Fields.Where(f => f.Type == FieldType.FieldTOC).Cast<FieldToc>().ToList()
    .ForEach(f => { f.InsertHyperlinks = true; f.HideInWebLayout = true; f.Update(); });

doc.Save(@"C:\Temp\out.docx");

@alexey.noskov Why I am getting it question mark symbol(?) in TOC? I need to show the only page number. Kindly help me.
Please find the below-mentioned screenshot.
image.png (8.6 KB)

@Manasahr Please call Document.UpdatePageLayout before saving the document to update page numbers in the TOC.
https://docs.aspose.com/words/net/working-with-table-of-contents/#updating-the-table-of-contents