Table Generator Plugin for Aspose.PDF
The Aspose.PDF Table Generator Plugin for .NET enables developers to insert, customize, and populate tables programmatically inside PDFs. Whether you need structured invoices, schedules, or data grids, this plugin offers flexible table creation and formatting to streamline any .NET document workflow.
Latest Articles
Aspose.PDF Table Generator Plugin Key Features
Dynamic Table Insertion Add new tables, rows, and cells on any page of a PDF file programmatically.
Rich Content Types Cells can contain text, HTML fragments, images, and even mathematical formulas (TeX support).
Custom Table Structure & Styling Fine-tune borders, alignment, fonts, and other properties to match your report or branding needs.
Batch and Programmatic Generation Automate large document generation or loop through datasets to populate tables efficiently.
Getting Started with Aspose.PDF Table Generator Plugin
Install Aspose.PDF for .NET Add the library from NuGet or download assemblies to your .NET project.
Configure Your License Apply license keys for unrestricted table creation.
Define and Populate Tables Use the
TableGenerator
,TableOptions
, and builder classes to insert tables, add rows/cells, and customize content.Process and Save Generate the PDF with tables and save or distribute the document as required.
Example: Add a Table to a PDF (C#)
using Aspose.Pdf.Plugins;
var generator = new TableGenerator();
var options = new TableOptions()
.AddDemoTable(1) // Add a sample table to page 1
.AddDemoTable(3); // Add a sample table to page 3
options.AddInput(new FileDataSource(@"C:\Samples\Results\table-generator-demo.pdf"));
options.AddOutput(new FileDataSource(@"C:\Samples\Results\table-generator-demo.pdf"));
var resultContainer = generator.Process(options);
Console.WriteLine(resultContainer.ResultCollection.Count);
Example: Custom Table Structure
public static TableOptions AddDemoTable(this TableOptions tableOptions, int pageNumber)
{
return tableOptions
.InsertPageAfter(pageNumber)
.AddTable()
.AddRow()
.AddCell().AddParagraph(new HtmlFragment("<b>Header 1 1</b>"))
.AddCell().AddParagraph(new TextFragment("Header 1 2"))
.AddCell().AddParagraph(new TextFragment("Header 1 3"))
.AddRow()
.AddCell().AddParagraph(new TeXFragment("The equation $E=mc^2$", true))
.AddCell().AddParagraph(new TextFragment("Cell 1 2"))
.AddCell().AddParagraph(new TextFragment("Cell 1 3"))
.AddRow()
.AddCell().AddParagraph(new TextFragment("Cell 1 1"))
.AddCell().AddParagraph(new TextFragment("Cell 1 3"));
}
Use Cases & Extensions
- Invoices & Financial Reports: Programmatically generate tables for line items, summaries, and totals.
- Schedules & Calendars: Build grids and timetables for event planning or resource allocation.
- Data Grids from External Sources: Loop through lists/arrays to populate tables dynamically.
- Rich-Content Cells: Insert images, HTML-formatted text, and math expressions into table cells.
For advanced formatting—custom borders, background color, or cell merging—see the API Reference and builder method documentation.
Best Practices
- Define table structure before inserting data for better layout control.
- Use builder methods to keep code readable and maintainable.
- Batch-generate documents for scalable solutions (e.g., mail merges, report generation).
Related Resources: