The Syncfusion .NET Word Library (DocIO) is a feature-rich and high-performance tool that allows users to create and update the table of contents (TOC) in a Word document using C#. Build the TOC based on heading and custom styles, including page numbers and hyperlinks for easy navigation.
Here is an example of how to update the table of contents in a Word document in C# using the Syncfusion .NET Word Library (DocIO).
//Load an existing Word document
using FileStream inputDocumentStream = new FileStream("Template.docx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
using WordDocument document = new WordDocument(inputDocumentStream, FormatType.Docx);
//Update the table of contents
document.UpdateTableOfContents();
//Save the Word document
using FileStream outputDocumentStream = new FileStream("Result.docx", FileMode.Create, FileAccess.ReadWrite);
document.Save(outputDocumentStream, FormatType.Docx);
Personalize the visual appearance of TOC entries, accommodating customization for up to 9 levels of entries.
Users can define custom styles along with their corresponding heading levels in the TOC, instead of default heading styles.
Modify the text of TOC entries, change tab leaders, customize heading levels, manage page numbers, hyperlinks, and more.
Greatness—it’s one thing to say you have it, but it means more when others recognize it. Syncfusion is proud to hold the following industry awards.