TocGenerator Plugin

Overview

The Aspose.Pdf.LowCode.TocGenerator plugin adds a table of contents to a PDF document. Configure the operation with TocOptions, add input and output data sources, and call Process.

Add a table of contents

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddTableOfContentsWithPlugin()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

    // Create PDF TocGenerator plugin
    using (var plugin = new Aspose.Pdf.LowCode.TocGenerator())
    {
        // Add input and output files
        var options = new Aspose.Pdf.LowCode.TocOptions();
        options.AddInput(new Aspose.Pdf.LowCode.FileDataSource(dataDir + "AddTable.pdf"));
        options.AddOutput(new Aspose.Pdf.LowCode.FileDataSource(dataDir + "AddTableOfContentsWithPlugin_out.pdf"));

        // Add table of contents
        var result = plugin.Process(options);

        // Get the path of the saved PDF document
        var outputPath = result.ResultCollection[0].ToFile();
    }
}

Result

Process returns one PDF result with the generated table of contents.