We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add the header in PdfLightTable

Platform: WinForms |
Control: PDF

The Syncfusion Essential PDF is a feature-rich and high-performance .NET PDF library used to create, read, and edit PDF documents programmatically without Adobe dependencies. This library also offers functionality to merge, split, stamp, forms, compress, and secure PDF files.

This sample explains how to add header in PdfLightTable.

Steps to add header in PdfLightTable programmatically in C#:

  1. Create a new C# console application project. Create console application in visual studioCreate console application in visual studio
  2. Install the Syncfusion.Pdf.WinForms NuGet package as a reference to your .NET Framework application from the NuGet.org. Refer NuGet package to the project
  3. Include the following namespaces in Program.cs file


using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf.Tables;
using System.Drawing;



Imports Syncfusion.Pdf
Imports Syncfusion.Pdf.Graphics
Imports Syncfusion.Pdf.Tables
Imports System.Drawing


  1. You can add header in a PdfLightTable by enabling the ShowHeader property of PdfLightTableStyle class.


//Add header to the table
lightTable.Style.ShowHeader = true;



'Add header to the table
lightTable.Style.ShowHeader = True


  1. Include the following code snippet in main method of Program.cs file to add header in PdfLightTable and apply the HeaderStyle.


//Create a new PDF document
PdfDocument document = new PdfDocument();
//Add a page to the PDF document
PdfPage page = document.Pages.Add();
//Create a PdfLightTable and set the DatSourceType 
PdfLightTable lightTable = new PdfLightTable();
lightTable.DataSourceType = PdfLightTableDataSourceType.TableDirect;
//Add columns to the table
lightTable.Columns.Add(new PdfColumn("Employee ID"));
lightTable.Columns.Add(new PdfColumn("Employee Name"));
lightTable.Columns.Add(new PdfColumn("Title"));
lightTable.Columns.Add(new PdfColumn("Birth Date"));
lightTable.Columns.Add(new PdfColumn("Hire Date"));
//Add rows to the table
lightTable.Rows.Add(new object[] { "E01", "Nancy Davolio", "Sales Representative", "12/8/1948", "5/1/1992" });
lightTable.Rows.Add(new object[] { "E02", "Andrew Fuller", "Vice President, Sales", "2/19/1952", "8/14/1992" });
lightTable.Rows.Add(new object[] { "E03", "Janet Leverling", "Sales Representative", "8/30/1963", "4/1/1992" });
lightTable.Rows.Add(new object[] { "E04", "Margeret Peacock", "Sales Representative", "9/19/1937", "5/3/1993" });
lightTable.Rows.Add(new object[] { "E05", "Steven Buchnam", "Sales Manager", "3/4/1955", "10/17/1993" });
lightTable.Rows.Add(new object[] { "E06", "Michael Suyama", "Sales Representative", "7/2/1963", "10/17/1993" });
lightTable.Rows.Add(new object[] { "E07", "Robert King", "Sales Representative", "5/29/1960", "1/2/1994" });
//Add header to the table
lightTable.Style.ShowHeader = true;
//Create a style for header using PdfCellStyle
PdfCellStyle headerStyle = new PdfCellStyle(new PdfStandardFont(PdfFontFamily.Helvetica, 10), PdfBrushes.OrangeRed, PdfPens.Black);
lightTable.Style.HeaderStyle = headerStyle;
//Draw the table on PDF page
lightTable.Draw(page, PointF.Empty);
//Save the PDF document
//Close the instance of PdfDocument



'Create a new PDF document
Dim document As PdfDocument = New PdfDocument
'Add a page to the PDF document
Dim page As PdfPage = document.Pages.Add
'Create a PdfLightTable and set the DatSourceType
Dim lightTable As PdfLightTable = New PdfLightTable
lightTable.DataSourceType = PdfLightTableDataSourceType.TableDirect
'Add columns to the table
lightTable.Columns.Add(New PdfColumn("Employee ID"))
lightTable.Columns.Add(New PdfColumn("Employee Name"))
lightTable.Columns.Add(New PdfColumn("Title"))
lightTable.Columns.Add(New PdfColumn("Birth Date"))
lightTable.Columns.Add(New PdfColumn("Hire Date"))
'Add rows to the table
lightTable.Rows.Add(New Object() {"E01", "Nancy Davolio", "Sales Representative", "12/8/1948", "5/1/1992"})
lightTable.Rows.Add(New Object() {"E02", "Andrew Fuller", "Vice President, Sales", "2/19/1952", "8/14/1992"})
lightTable.Rows.Add(New Object() {"E03", "Janet Leverling", "Sales Representative", "8/30/1963", "4/1/1992"})
lightTable.Rows.Add(New Object() {"E04", "Margeret Peacock", "Sales Representative", "9/19/1937", "5/3/1993"})
lightTable.Rows.Add(New Object() {"E05", "Steven Buchnam", "Sales Manager", "3/4/1955", "10/17/1993"})
lightTable.Rows.Add(New Object() {"E06", "Michael Suyama", "Sales Representative", "7/2/1963", "10/17/1993"})
lightTable.Rows.Add(New Object() {"E07", "Robert King", "Sales Representative", "5/29/1960", "1/2/1994"})
'Add header to the table
lightTable.Style.ShowHeader = True
'Create a style for header using PdfCellStyle
Dim headerStyle As PdfCellStyle = New PdfCellStyle(New PdfStandardFont(PdfFontFamily.Helvetica, 10), PdfBrushes.OrangeRed, PdfPens.Black)
lightTable.Style.HeaderStyle = headerStyle
'Draw the table on PDF page
lightTable.Draw(page, PointF.Empty)
'Save the PDF document
'Close the instance of PdfDocument


  1. You can repeat the header on each page in PdfLightTable by enabling the RepeatHeader property of PdfLightTableStyle class.


//Repeat the header on each page for the table
lightTable.Style.RepeatHeader = true;



'Repeat the header on each page for the table
lightTable.Style.RepeatHeader = True


A complete work sample to add header and apply style to it in PdfLightTable can be downloaded from TableHeader.zip.

By executing the program, you will get the PDF document as follows.

Table with header

Take a moment to peruse the documentation, where you will find other options like simple table creation, table customization, adding multiple tables, row and column spanning, row styles, cell styles, string formatting and more both in PdfLightTable and PdfGrid.

Click here to know the differences between PdfLightTable and PdfGrid.

Click here to explore the rich set of Syncfusion Essential PDF features.

An online sample link for different table features.


Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.


2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile