I am trying to create a pdf file in Java using PDFBox. The file is to contain a large table with 2 columns. To render tables insidde the pdf, I am using another library: boxable.
The file is successfully created and the table is also rendered. But problem arise when one of the row contain large data. In that case, the table splits and does not display data properly:
The large row is moved automatically to a new page while the first page remains empty. In the second page, the row ends abruptly at New task entered for testing without displaying entire data in the cell. This is a recurring issue and is not specific to this case.
Row<PDPage> headerRow;
Row<PDPage> row;
Cell<PDPage> cell;
int i;
headerRow = table.createRow(15f);
cell = headerRow.createCell(30, "Goal Category");
cell.setFont(PDType1Font.HELVETICA);
cell.setFontSize(11);
cell = headerRow.createCell(70, "My Goal");
cell.setFont(PDType1Font.HELVETICA);
cell.setFontSize(11);
table.addHeaderRow(headerRow);
for(i=0;i<goals.size();i++)
{
ArrayList<String> goal=goals.get(i);
row = table.createRow(12);
cell = row.createCell(30, goal.get(0));
cell.setFont(PDType1Font.HELVETICA);
cell.setFontSize(11);
System.out.println("My Goal="+goal.get(1));
cell = row.createCell(70, goal.get(1));
cell.setFont(PDType1Font.HELVETICA);
cell.setFontSize(11);
}
table.draw();
I am looking for a solution or an alternate way to render tables in pdf.