我有一些适用于iText 2.1.7的代码。我们决定转移到最新版的iText。我用5.5.6版测试了代码,代码也运行得很好。
当上个月发布版本5.5.7时,我们决定升级到该版本,因为它在使用嵌套表和拆分似乎与项目相关的行时有一些关于性能的修复。
但是在某些情况下,当表因分页而分裂时,会向PDF添加空白页。正如我所说,代码适用于iText 2.1.7和iText 5.5.6。
以下是用于构建表的代码:
float[] widthsIllustration = { 0.75f, 8 };
PdfPTable tableIllustration = ReportBuilderCommon.buildTable(2, 100, widthsIllustration);
tableIllustration.setSplitLate(false);
tableIllustration.getDefaultCell().setBorder(Rectangle.BOTTOM);
tableIllustration.getDefaultCell().setPaddingBottom(5);
上表嵌套在另一个像这样创建的表中
PdfPTable leftColumn = ReportBuilderCommon.buildTable(1, 100);
leftColumn.setSplitLate(false);
以下是方法buildTable
:
public static PdfPTable buildTable(final int numColums, final float widthPercentage) throws DocumentException {
PdfPTable table = new PdfPTable(numColums);
table.setWidthPercentage(widthPercentage);
table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
return table;
}