PDF Table Generator

The Documentize Table Generator for .NET is a versatile plugin designed to streamline the integration of tables into PDF documents. Whether you’re organizing data, designing forms, or improving document readability, this plugin simplifies the process while maintaining precision and efficiency. Its intuitive API supports both single document and batch processing workflows, making it an essential tool for developers working with structured data.

Key Features:

  • Dynamic Table Creation: Effortlessly generate structured tables in PDF documents.
  • Rich Content Support: Populate tables with text, HTML, images, and LaTeX content.
  • Page Placement: Insert tables at specific locations within a PDF with precision.
  • Customizable Layout: Adjust table structure, cell alignment, and styling.
  • Batch Processing: Process multiple documents simultaneously for maximum efficiency.

Creating a PDF with Tables

Follow these steps to create structured tables in a PDF using the TableGenerator class:

  1. Instantiate the TableGenerator class.
  2. Configure the TableOptions object to define table structure, content, and input/output files.
  3. Add tables, rows, and cells to your PDF.
  4. Finalize the table generation process using the Process method.

Here’s an example:

 1var generator = new TableGenerator();
 2var options = new TableOptions();
 3
 4// Specify input and output PDF files
 5options.AddInput(new FileDataSource("input.pdf"));
 6options.AddOutput(new FileDataSource("output.pdf"));
 7
 8// Define a table with rows and cells
 9options
10    .InsertPageAfter(1) // Add table after the first page
11    .AddTable()
12        .AddRow()
13            .AddCell().AddParagraph(new TextFragment("Cell 1"))
14            .AddCell().AddParagraph(new TextFragment("Cell 2"))
15            .AddCell().AddParagraph(new TextFragment("Cell 3"));
16
17// Generate the table in the document
18generator.Process(options);

Adding Rich Content to Tables

Tables in PDF documents can include a variety of content types to enhance their functionality and appearance. Below is an example of adding HTML content to table cells:

1options
2    .AddTable()
3        .AddRow()
4            .AddCell().AddParagraph(new HtmlFragment("<h1>Header 1</h1>"))
5            .AddCell().AddParagraph(new HtmlFragment("<h2>Header 2</h2>"))
6            .AddCell().AddParagraph(new HtmlFragment("<h3>Header 3</h3>"));

Supported Content Types in Tables

The PDF Table Generator supports various content types, enabling developers to customize tables for a wide range of use cases:

  • HtmlFragment: Add HTML-based content, such as headers, lists, and formatted text.
  • TeXFragment: Include LaTeX-based content for mathematical equations and scientific notation.
  • TextFragment: Insert plain or formatted text.
  • Image: Embed images directly into table cells.

Customizing Table Layout and Structure

The plugin provides flexibility for adjusting table structure, including row height, column width, and cell alignment. These customization options allow you to design tables that match your document’s layout and styling needs.

Processing the Table Generation

After adding all content and customizing the table structure, finalize the process by calling the Process method. This method generates the tables and updates the PDF document. Here’s how to handle the results:

1var resultContainer = generator.Process(options);
2
3// Output the number of generated results
4Console.WriteLine("Number of results: " + resultContainer.ResultCollection.Count);

Use Cases for the PDF Table Generator

  1. Data Reporting: Present analytics, financial reports, or survey results in a clear and organized format.
  2. Form Design: Create interactive forms with structured table layouts.
  3. Document Enhancement: Improve the readability and usability of user manuals, guides, or instructional materials.
  4. Batch Processing: Automate table generation for multiple PDF documents.
 English