Java – How to write page headers when using iText library in java

itextjava

I am developing a report generation application that could have tabular data across multiple pages. I am using pdfTable to create tabular data. I am issues with adding page headers. The problem is that when I add page header onEndPage event handler, I am not get the table to start after certain gap so that header is visible.

Best Solution

If you are using tables (PDFPTable) for your layout then you can use: table.setHeaderRows(2);

JavaDoc Link : http://api.itextpdf.com/com/itextpdf/text/pdf/PdfPTable.html