TableGenerator Plugin

Overview

The Aspose.Pdf.LowCode.TableGenerator plugin adds tables to PDF documents. Configure the table with TableOptions, add input and output data sources, and call Process.

Add a table to a PDF document

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

    // Create PDF TableGenerator plugin
    using (var plugin = new Aspose.Pdf.LowCode.TableGenerator())
    {
        // Configure table options
        var options = Aspose.Pdf.LowCode.TableOptions.Create();
        options.AddTable()
            .AddRow()
                .AddCell()
                    .AddParagraph(new Aspose.Pdf.Text.TextFragment("Header 1"))
                .AddCell()
                    .AddParagraph(new Aspose.Pdf.Text.TextFragment("Header 2"));
        options.AddInput(new Aspose.Pdf.LowCode.FileDataSource(dataDir + "AddTable.pdf"));
        options.AddOutput(new Aspose.Pdf.LowCode.FileDataSource(dataDir + "AddTableWithPlugin_out.pdf"));

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

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

Options

Use TableOptions.Create() and its builders to add tables, rows, cells, and cell paragraphs.