Java 如果keepTogether设置为true,为什么PdfPTable在段落中不可见?
我正在使用OpenPdf 1.3.8(itext的fork)和OpenJDK1.8.0192 我试图用两个文本(一个在上面,一个在下面)对表进行分组,以防止在页面上剩余的空白空间中出现元素分裂 元素添加到段落中,keepTogether设置为true。我注意到使用setKeepTogether时的特殊行为(true) 如果调用setKeepTogether(true),则表不会出现,其他元素将: 如果setKeepTogether(false)-一切正常: 下面是我的代码示例:Java 如果keepTogether设置为true,为什么PdfPTable在段落中不可见?,java,itext,openpdf,Java,Itext,Openpdf,我正在使用OpenPdf 1.3.8(itext的fork)和OpenJDK1.8.0192 我试图用两个文本(一个在上面,一个在下面)对表进行分组,以防止在页面上剩余的空白空间中出现元素分裂 元素添加到段落中,keepTogether设置为true。我注意到使用setKeepTogether时的特殊行为(true) 如果调用setKeepTogether(true),则表不会出现,其他元素将: 如果setKeepTogether(false)-一切正常: 下面是我的代码示例: public
public static void main(String[] args) throws DocumentException, FileNotFoundException {
Document document = new Document();
PdfWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream(DEST));
document.open();
PdfPTable table = new PdfPTable(2);
table.addCell("Lorem");
table.addCell("ipsum");
table.addCell("dolor");
table.addCell("sit");
Paragraph mainParagraph = new Paragraph();
Paragraph paragraph1 = new Paragraph("Text above table");
Paragraph paragraph2 = new Paragraph("Text below table");
mainParagraph.add(paragraph1);
mainParagraph.add(table);
mainParagraph.add(paragraph2);
// if keeptogether is true, table is not visible
mainParagraph.setKeepTogether(true);
document.add(mainParagraph);
document.close();}
关于发生了什么有线索吗
代码也用itext 5.5.13进行了测试。在这两种情况下,itext表都是可见的。最后,我在project上发布了相同的问题。事实证明这是一个bug,自版本1.3.12以来,这个bug已经被修复。最后,我在project上发布了相同的问题。事实证明这是一个bug,自版本1.3.12以来,该bug已经修复。