Добавить таблицу
The Documentize PDF Manager for .NET is a versatile component designed to streamline the integration of tables into PDF documents. Whether you’re organizing data, designing forms, or improving document readability, this component simplifies the process while maintaining precision and efficiency.
Creating a PDF with Tables
Follow these steps to create structured tables in a PDF using the TableOptions class:
- Configure the
TableOptionsobject to define table structure, content, and input/output files. - Add tables, rows, and cells to your PDF.
- Finalize the table generation process using the
AddTablemethod.
Here’s an example:
1// Configure table options
2var options = new TableOptions();
3options.InsertPageBefore(1)
4 .AddTable()
5 .AddRow()
6 .AddCell().AddParagraph("Name")
7 .AddCell().AddParagraph("Age")
8 .AddRow()
9 .AddCell().AddParagraph("Bob")
10 .AddCell().AddParagraph("12")
11 .AddRow()
12 .AddCell().AddParagraph("Sam")
13 .AddCell().AddParagraph("20")
14 .AddRow()
15 .AddCell().AddParagraph("Sandy")
16 .AddCell().AddParagraph("26")
17 .AddRow()
18 .AddCell().AddParagraph("Tom")
19 .AddCell().AddParagraph("12")
20 .AddRow()
21 .AddCell().AddParagraph("Jim")
22 .AddCell().AddParagraph("27");
23// Add input file path
24options.AddInput(new FileData("path_to_input.pdf"));
25// Set output file path
26options.AddOutput(new FileData("path_to_output.pdf"));
27// Perform the process
28PdfManager.AddTable(options);Set page of the table
Follow these steps to create table in a PDF before 2 page: Here’s an example:
1// Configure table options
2var options = new TableOptions();
3options.InsertPageBefore(2) // Add table before page 2
4 .AddTable()
5 .AddRow()
6 .AddCell().AddParagraph("Name")
7 .AddCell().AddParagraph("Age");
8// Add input file path
9options.AddInput(new FileData("path_to_input.pdf"));
10// Set output file path
11options.AddOutput(new FileData("path_to_output.pdf"));
12// Perform the process
13PdfManager.AddTable(options);Key Features:
- Dynamic Table Creation: Effortlessly generate structured tables in PDF documents.
- Page Placement: Insert tables at specific locations within a PDF with precision.
- Customizable Layout: Adjust table structure, cell alignment, and styling.