Hi !
I wanted to know the number of pages after adding a table to the page. The otuput that I expect is greater than one, because the table is distributed over several pages. Is there a way to update the document? The “doc.updatePages ();” method, throws an exception, “Null Pointer Exception”
Document doc = new Document();
doc.setPageLayout(PageMode.UseNone);
Page page = doc.getPages().add();
Table tab = new Table();
tab.setRepeatingRowsCount(1);
tab.setDefaultCellPadding(new MarginInfo(2, 2, 2, 2));
Row row = tab.getRows().add();
row.getDefaultCellTextState().setFontStyle(FontStyle.CourierBold);
row.getCells().add("HELLO");
for (int j = 0; j < 100; j++) {
row = tab.getRows().add();
row.getCells().add("50");
}
page.getParagraphs().add(tab);
System.out.println(doc.getPages().size());
doc.save("report.pdf");
page.getParagraphs().add(tab);
System.out.println(doc.getPages().size());
doc.save("report.pdf");