1
在我的Java项目中使用Itext我创建了一个pdf文件,在这里我在另一个表格的单元格中插入一个更大的表格。iText在另一个表格的单元格内嵌套大表格
我在面对的问题是当表的内容大于一页时,表被带到下一页。相反,我想要在上一页的数据的一部分,只有那些超过页面的数据需要转到下一页。
如何实现这一点,下面是我使用的代码。
PdfPTable outerTable = new PdfPTable(2);
outerTable.setHeaderRows(1);
outerTable.setSpacingBefore(20);
outerTable.setWidthPercentage(100);
Phrase str_head = new Phrase("Sample Image \n", subFont);
Phrase act_head = new Phrase("Steps \n", subFont);
PdfPCell cell2;
cell2 = new PdfPCell(act_head);
outerTable.addCell(cell2);
cell2 = new PdfPCell(str_head);
cell2.setBorder(Rectangle.NO_BORDER);
outerTable.addCell(cell2);
/* content row*/
cell2 = new PdfPCell("-----Sample-------");
cell2.setBorder(Rectangle.NO_BORDER);
outerTable.addCell(cell2);
PdfPTable innerTable = new PdfPTable(2);
---------------
---------------
innerTable.add("XXX")//add more rows in so that page will overlow
---------------
---------------
cell2 = new PdfPCell(innerTable);
cell2.setBorder(Rectangle.NO_BORDER);
outerTable.addCell(cell2);
设置PdfPTable的SplitRows。 – VahidN