How to hide header in PDF tables using C# and VB.NET?
Syncfusion Essential PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can hide header in PDF tables using C# and VB.NET.
Steps to hide header in PDF tables programmatically:
- Create a new C# Windows Forms application project.

- Install the Syncfusion.Pdf.WinForms NuGet package as reference to your .NET Framework application from NuGet.org.

- Include the following namespaces in Form.cs file.
C#
using Syncfusion.Pdf; using Syncfusion.Pdf.Grid; using System.Drawing;
VB.NET
Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Grid Imports System.Drawing
- Use the following code snippet to hide header in PDF tables.
C#
int count;
private void button1_Click(object sender, EventArgs e)
{
//Initialize count to 0
count = 0;
//Create a new PDF document
PdfDocument document = new PdfDocument();
//Add a page
PdfPage page = document.Pages.Add();
//Create a PdfGrid
PdfGrid pdfGrid = new PdfGrid();
//Create a DataTable
DataTable dataTable = new DataTable();
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable
dataTable.Rows.Add(new object[] { "E01", "Mark" });
dataTable.Rows.Add(new object[] { "E02", "Chad" });
//Assign data source
pdfGrid.DataSource = dataTable;
pdfGrid.BeginCellLayout += PdfGrid_BeginCellLayout;
//Draw grid to the page of PDF document
pdfGrid.Draw(page, new PointF(10, 10));
//Save and close the document
document.Save("HideHeaderInPDFTables.pdf");
document.Close(true);
}
private void PdfGrid_BeginCellLayout(object sender, PdfGridBeginCellLayoutEventArgs args)
{
count++;
PdfGrid grid = (sender as PdfGrid);
if (count <= grid.Headers.Count * grid.Columns.Count)
{
args.Skip = true;
}
}
VB.NET
Private count As Integer
Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
'Initialize count to 0
count = 0
'Create a new PDF document
Dim document As PdfDocument = New PdfDocument()
'Add a page
Dim page As PdfPage = document.Pages.Add()
'Create a PdfGrid
Dim pdfGrid As PdfGrid = New PdfGrid()
'Create a DataTable
Dim dataTable As DataTable = New DataTable()
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable
dataTable.Rows.Add(New Object() {"E01", "Mark"})
dataTable.Rows.Add(New Object() {"E02", "Chad"})
'Assign data source
pdfGrid.DataSource = dataTable
AddHandler pdfGrid.BeginCellLayout, New PdfGridBeginCellLayoutEventHandler(AddressOf PdfGrid_BeginCellLayout)
'Draw grid to the page of PDF document
pdfGrid.Draw(page, New PointF(10, 10))
'Save and close the document
document.Save("HideHeaderInPDFTables.pdf")
document.Close(True)
End Sub
'BeginCellLayout event to hide headers
Private Sub PdfGrid_BeginCellLayout(ByVal sender As Object, ByVal args As PdfGridBeginCellLayoutEventArgs)
count += 1
Dim grid As PdfGrid = (TryCast(sender, PdfGrid))
If count <= grid.Headers.Count * grid.Columns.Count Then
args.Skip = True
End If
End Sub
A complete working sample can be downloaded from HideHeaderInPDFTables.zip.
By executing the program, you will get the PDF document as follows. 
Take a moment to peruse the documentation for working with tables, where you will find other options like grid pagination and different levels of grid customization.
Refer here to explore the rich set of Syncfusion Essential PDF features.
An online sample link to create a richly formatted table.
Note:
Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message.
Conclusion:
I hope you enjoyed learning about how to hide header in PDF tables using C# and VB.NET.
You can refer to our Flutter PDF feature tour page to learn about its other groundbreaking features and documentation, and how to quickly get started with configuration specifications. You can also explore our Flutter PDF Flutter PDF examples to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to explore our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums or feedback portal. We are always happy to assist you!