Create Table in PDF Files in C# .NET

Tables are used to represent data in the form of rows and columns. A table lets the readers go through the data quickly without reading a lot of text. When generating the PDF files programmatically, you may often come across the requirement of creating tables. In accordance with that, this article covers how to create a table in PDF files in C# .NET.

C# .NET API to Create Table in PDF - Free Download

We will use Aspose.PDF for .NET to create tables in PDF files. The API is designed to perform PDF generation and manipulation within the .NET applications. It allows you to create PDF files of simple and complex layouts seamlessly. You can either download the API’s binaries or install it using NuGet.

PM> Install-Package Aspose.PDF

Create a Table in a PDF in C#

You can create tables in either a new or an existing PDF file using Aspose.PDF for .NET. The following are the steps to create a table in a PDF file in C#.

The following code sample shows how to create a table in a PDF file using C#.

The following is the output of the above code sample.

Create a Table in a PDF File in C#

C# Create PDF Table with Customized Borders and Margins

You can also customize the borders and margins of the tables in PDF as per your requirements. For example, you can set the border width, border style, and top, bottom, left, and right margins. The following are the steps to set borders and margins for the tables in PDF files in C#.

The following code sample shows how to set borders and margins for tables in PDF using C#.

The following screenshot shows the output of the above code sample.

Create PDF Table with Customized Borders and Margins C#

C# Apply Column Adjustment to PDF Tables

Aspose.PDF for .NET also allows you to customize the column adjustment of the table in a PDF. For example, you can auto-fit the table to the window or the content. The following are the steps to set the column adjustment of a table in PDF using C#.

The following code sample shows how to set the column adjustment of the table in PDF using C#.

C# .NET PDF API to Create Tables - Get a Free License

You can get a free temporary license in order to use Aspose.PDF for .NET without evaluation limitations.

Conclusion

In this article, you have learned how to create tables in PDF files using C#. Furthermore, you have seen how to customize the borders. margins, and column adjustment of a table in PDF. Besides, you can explore more about the C# PDF API using the documentation. In case you would have any questions or queries, you can contact us via our forum.

See Also