【发布时间】:2016-12-06 02:55:55
【问题描述】:
我正在尝试使用 Java 中的 IText 7 创建一个 pdf 文档。但是表格内容没有显示在 pdf 中。
代码片段:
private void addReceiptDetails(Document doc) {
Table table = new Table(2, true);
table.addCell(new Cell().add("C1"));
table.addCell(new Cell().add("C2"));
for (TaxTypeModel taxType : sale.getTaxModel().getTaxTypeModelList()) {
table.addCell(new Cell().add("C9"));
table.addCell(new Cell().add("C10"));
}
table.addCell(new Cell().add("C3"));
table.addCell(new Cell().add("C4"));
table.addCell(new Cell().add("C5"));
table.addCell(new Cell().add("C6"));
table.addCell(new Cell().add("C7"));
table.addCell(new Cell().add("C8"));
doc.add(table);
table.complete();
doc.close();
}
PDF 表格内容:
有人可以帮我吗?我不确定这里到底出了什么问题。
编辑:我尝试了来自here 的代码示例:
Table table = new Table(8);
for (int i = 0; i < 16; i++) {
table.addCell("hi");
}
doc.add(table);
这也只是创建空单元格。
【问题讨论】: