Table of contents

Is there a way to insert a table of contents in a word document that could take into account of the titles and subtitles and update itself when we ask ?

@Flyomega

Yes, you can insert a Table of Contents in a Word document using InsertField. You need to set the following parameters of the API for your requirements. Please check the sample values and cURL command for your reference.

Name = Sample_Document.docx
FieldCode = {TOC}
NodePath = sections/0/paragraphs/0
DestFileName = Sample_TOC.docx

curl -v "https://api.aspose.cloud/v4.0/words/Sample.docx/sections%2F0%2Fparagraphs%2F0/fields?destfilename=Sample_TOC.docx" 
-X POST 
-H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6I.......opXAZ50HZ2TpSxg" 
-H "Content-Type: application/json" 
-d "{ \"FieldCode\": \"{TOC}\" }" 
1 Like