Xceed Words for .NET v5.0 Documentation
Welcome to Xceed Words for .NET v5.0 / Code Snippets / Inserting a Table of Contents at the end of a document
In This Topic
    Inserting a Table of Contents at the end of a document
    In This Topic

    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();
          }
        }