How to write page headers when using iText library in java
Question
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.
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
OTHER TIPS
If I understand this correctly, you just need to change your margins, so table will start after header.
From http://www.docjar.org/docs/api/com/lowagie/text/Document.html
public Document(Rectangle pageSize,
float marginLeft,
float marginRight,
float marginTop,
float marginBottom)
For example:
final Document document = new Document(PageSize.A4, 50, 50, 165, 50);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow