I using itexpdf to generate a large table, when I set setHeaderRows, the first rows displayed in a page are repeat in the next page. I.e. in the following code
Document document = new Document(new Rectangle(605, 784), 28, 28, 42, 28);
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("/temp/tabla.pdf"));
document.open();
PdfPTable tabla = new PdfPTable(5);
tabla.setComplete(false);
tabla.setWidthPercentage(100);
tabla.getDefaultCell().setBackgroundColor(BaseColor.WHITE);
tabla.setHeaderRows(5);
for(int i=1; i<=5; i++)
{
celda = new PdfPCell();
Paragraph encabezado = new Paragraph("Header "+i);
celda.addElement(encabezado);
celda.setGrayFill(0.8f);
tabla.addCell(celda);
}
for(int k=0; k<300; k++)
{
celda = new PdfPCell();
Paragraph contenido = new Paragraph("Cell "+k, helvetica11);
celda.addElement(contenido);
tabla.addCell(celda);
}
tabla.completeRow();
document.add(tabla);
document.close();
To run shown a table in two pages, has the same header but the first four rows are repeated on both pages.
I should do so that don't repeat any row?
When I see tabla.setHeaderRows(5);
I expect the first five rows to be repeated. That is: the first row with the 5 header cells and the first 4 rows of data.
Are you sure you didn't mean to write tabla.setHeaderRows(1);
?