Reputation: 203
How can I get iTextSharp to repeat the headers of a PdfPTable on each page of the generated PDF?
Upvotes: 19
Views: 27535
Reputation: 715
You can use the HeaderRows as follows:
var dataDetails = new PdfPTable(6);
dataDetails.HorizontalAlignment = 0;
dataDetails.WidthPercentage = 100;
dataDetails.SpacingBefore = 10;
dataDetails.SpacingAfter = 10;
dataDetails.DefaultCell.Border = 0;
dataDetails.HeaderRows = 1;
dataDetails.SetWidths(new int[] { 1, 3, 1, 1, 1, 1 });
Upvotes: 1
Reputation: 53593
You just need to set the PdfPTable.HeaderRows
property to the number of rows in your PdfPTable
's header like this:
table.HeaderRows = 1;
Upvotes: 38