Free Support Forum - aspose.com

How to implement TOC - Table of Contents

Hi,

We are intrested in evaluvating u r product. Could u please explain us the steps how to create TOC programatically from the generated document.

Thanks.

Regards,
Kanndasan. A

Hi,

Thank you for interest in Aspose products.

You can insert table of contents field using DocumentBuilder.InsertTableOfContents:


Document doc = new Document(“my.doc”);

DocumentBuilder builder = new DocumentBuilder(doc);

builder.InsertTableOfContents(@"\o ““1-3"” \h \z \u”);

doc.Save(“result.doc”);


Please note that when you open the file in MS Word, the fields are not automatically updated unless you select a field (or select all document) and press F9.