Miss Take
Miss Take

Reputation: 71

Repeat header rows when exporting to PDF using iTextSharp

I'm trying to export a table to a pdf document.

My problem is that the header row is only in the first page, and i can't figure out how to make it repeat.

Couldn't find a solution online. I'm using ASP.NET and the export to pdf is with iTextSharp.

Upvotes: 2

Views: 4011

Answers (1)

Bruno Lowagie
Bruno Lowagie

Reputation: 77528

When creating a PdfPTable object, you can define a row as a header row like this:

table.HeaderRows = 1;

If you need more than one header row, change 1 into another number.

If you also need footer rows, you need to be careful. Suppose that you want 2 header rows and 1 footer row, then you need something like this:

table.HeaderRows = 3; // 2 header rows + 1 footer row
table.FooterRows = 1;

I know this is awkward, but there are historical reasons for this. You need to set the HeaderRows to the number of all rows that need to be repeated (header and footer rows) and then define the number of actual footer rows.

Upvotes: 3

Related Questions