I'm generating a PDF document with iText 5.5.8 In this document there are numbered paragraphs that only contain a title Paragraph and a PdfPTable.
for (Item item : getItems()) {
Paragraph title = new Paragraph();
Chunk chunk = new Chunk(new Chunk(getIcon(item), 0, 0));
addBookmark(item, chunk);
title.add(chunk);
Chunk chunk2 = new Chunk(getName(item), catFont_u);
title.add(chunk2);
title.setSpacingBefore(20);
title.setSpacingAfter(14);
PdfPTable table = createTable(item); // can be more than a page!
table.setKeepTogether(true);
Section subSection = chapter.addSection(title);
subSection.add(table);
}
Now when the table is larger that te space left in the rest of the page, the table will be 'moved' to the next page (setKeepTogether()). This is good. However, I want the title Paragraph to always be on the same page as the PdfPTable. So the title Paragraph should be moved to the next page also.
How do I accomplish this?
Thanks,
Carel