Xceed Words for .NET v3.0 Documentation
Inserting a Table of Contents at the end of a document
Welcome to Xceed Words for .NET v3.0 > Code Snippets > Inserting a Table of Contents at the end of a document

The following example demonstrates how to add a Table of Contents at the end of a Document.

C#
Copy Code
    private void AddTableOfContents( string file )
    {
      using( var document = DocX.Load( file ) )
      {
        // Add a page break to place the Table of Content on a new page
        document.InsertSectionPageBreak();

        // Add the Table of Contents
        document.InsertTableOfContents( "Table of Contents", TableOfContentsSwitches.None );

        // Save the changes to the document
        document.Save();
      }
    }