How to Repeat Table Headers Across all WinForms PDF Pages?
Repeat table headers across all the PDF pages
To repeat the PdfGrid headers on all the pages of a PDF document, we can add the headers using the PdfGridHeaderCollection class and enable the RepeatHeader property to repeat the header in the grid table in our WinForms PDF feature tour page.
Please refer to the following code example on how to repeat the headers in a PDF grid table:
C#
// Create a new PDF document.
PdfDocument pdfDocument = new PdfDocument();
PdfPage pdfPage = pdfDocument.Pages.Add();
// Create a new PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
// Add three columns.
pdfGrid.Columns.Add(3);
// Add header.
pdfGrid.Headers.Add(1);
pdfGrid.RepeatHeader = true;
PdfGridRow pdfGridHeader = pdfGrid.Headers[0];
pdfGridHeader.Cells[0].Value = "Employee ID";
pdfGridHeader.Cells[1].Value = "Employee Name";
pdfGridHeader.Cells[2].Value = "Salary";
for (int i = 0; i < 60; i++)
{
// Add rows.
PdfGridRow pdfGridRow = pdfGrid.Rows.Add();
pdfGridRow.Cells[0].Value = "Employee 1";
pdfGridRow.Cells[1].Value = "John";
pdfGridRow.Cells[2].Value = "$10,000";
}
// Draw the PdfGrid.
pdfGrid.Draw(pdfPage, PointF.Empty);
// Save the document.
pdfDocument.Save("Output.pdf");
// Close the document.
pdfDocument.Close(true);
I hope you enjoyed learning about how to repeat table headers across all WinForms PDF pages.
You can refer to our WinForms 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 WinForms 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 check out 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!