Saving (heading) paragraph and table together on one page?

I am creating a PDF document with iText 5.5.8 This document has numbered paragraphs containing only the Paragraph and PdfPTable headings.

    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 that the table is larger than the left side of the remaining page, the table will be "moved" to the next page (setKeepTogether ()). It's good. However, I want the Paragraph header to always be on the same page as the PdfPTable. Therefore, the title should be moved to the next page.

How to do it?

Thank,

Karelian

+4
source share
1 answer

. (). innerTable, , , . , setsplitLate (false).

0

All Articles