1
我正在根据列表的大小生成表。 该表设置为适合avery表格,有列和13行。iText嵌套表 - 第一行未呈现
当列表大小小于5时,不显示任何内容。 如果列表大小为5或更大,则显示正确。
Document doc = new Document(PageSize.A4, pageMargin, pageMargin, pageMargin, pageMargin);
//5 rows for the table
PdfPTable table = new PdfPTable(5);
for (int i = 0; i < list.size(); i++) {
Object obj = list.get(i);
//this is the superior cell
PdfPCell cell = new PdfPCell();
cell.setFixedHeight(60.4f);
// Nested Table, table in the cell
PdfPTable nestedTable = new PdfPTable(2);
nestedTable.setWidthPercentage(100);
nestedTable.setWidths(new int[] { 24, 76 });
// First Cell in nested table
PdfPCell firstCell = new PdfPCell();
// fill cell...
// second cell in nested table
PdfPCell secondCell = new PdfPCell();
// fill cell
// put both cells into the nestedTable
nestedTable.addCell(firstCell);
nestedTable.addCell(secondCell);
// put nestedTable into superior table
cell.addElement(nestedTable);
table.addCell(cell);
}
doc.add(table);
doc.close();
对不起,我必须错过未完成的行。 table.completeRow()是解决方案,再次感谢! – nextcard