This quick tutorial describes how to insert table in PDF using C#. It provides the resource to set the development environment, step-by-step program flow to accomplish the task, and a runnable sample code to insert table into PDF using C#. You will also learn to format the table as per your requirements and then save the output file on the disk.
Steps to Add Table to PDF using C#
- Establish the environment to add Aspose.PDF for .NET to insert a table in a PDF
- Create a new PDF file using the Document class object to add a table
- Create a new table and set the default cell border
- Create multiple rows and add desired columns to them with sample values
- Get access to the first page of the PDF and add the table to it
- Save the PDF file having a table in it
These steps are sufficient to add table in PDF using C# such that first the link is provided to add the required resources into the project followed by the step-wise process for writing the application. First, we create a PDF file and then create a new table whose cells are formatted. Then multiple rows are added along with some value and added to the table that is finally added to the PDF.
Code to Insert table to PDF using C#
This code demonstrates the process to add a table in Adobe Acrobat using C# where a table is created having a collection of rows that is populated in a loop to fill the newly created table. The Table class has a property DefaultCellBorder that is set using the BorderInfo() object for formatting the cells in the table. Each page of the PDF file has a collection of paragraphs that allows inserting the table node into it.
This article has taught us to add table in Adobe Acrobat using C#. If you want to learn the process to read an existing table from a PDF, refer to the article on how to convert PDF to Word using C#.