gpt4 book ai didi

java - 将(标题-)段落和表格放在一页上?

转载 作者:搜寻专家 更新时间:2023-11-01 03:48:30 25 4
gpt4 key购买 nike

我正在使用 iText 5.5.8 生成 PDF 文档在本文档中,有编号的段落仅包含标题段落和 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);
}

现在当表格大于页面剩余空间时,表格将“移动”到下一页(setKeepTogether())。这很好。但是,我希望标题段落始终与 PdfPTable 在同一页上。所以标题段落也应该移到下一页。

我该如何实现?

谢谢,

卡雷尔

最佳答案

您可以创建一列的外表。然后添加您的段落(标题)。之后创建另一个表 innerTable,您可以在此处放置数据,然后将内部表添加到单元格,然后将该单元格添加到外部表。这样你的title和table就在一起了,也让outer table setsplitLate(false)。

关于java - 将(标题-)段落和表格放在一页上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35845422/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com