table -PDFbox 中的值被覆盖
values are getting overwritten in the table -PDFbox
我想按行和列显示记录集。我正在获取输出,但问题是,它正在重叠。我应该修改循环有人可以建议吗?
ArrayList<ResultRecord> Records = new ArrayList<ResultRecord>(MainRestClient.fetchResultRecords(this.savedMainLog));
for(j=0; j<Records.size(); j++)
{
Row<PDPage> row4 = table.createRow(100.0f);
Cell<PDPage> cell10 = row4.createCell(15.0f, temp.getNumber());
Cell<PDPage> cell11 = row4.createCell(45.0f, temp.getDescription());
Cell<PDPage> cell12 = row4.createCell(15.0f, temp.getStatus());
Cell<PDPage> cell13 = row4.createCell(25.0f, temp.getRemarks());
}
以下是打开 PDF 文件的完整代码。我想在相应单元格的 row4 中检索记录集。但是一个写在另一个上面。
预期输出:
IT 应该一个一个地显示在另一个下方。
是重叠的原因,是因为定义行为row4.
try {
//table.draw();
cell.setFontSize(12);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
首先,你应该弄清楚你使用的table绘图库。 PDFBox 只是底层的 PDF 库。考虑到使用的 类 我会假设你在它上面使用 Boxable。
此外,所有 table 相互重叠打印的原因是您在同一页上的相同位置开始每个 table,您使用
BaseTable table = new BaseTable(yPosition, yStartNewPage,
bottomMargin, tableWidth, margin, document, page, true, drawContent);
无需更改 yPosition
或 page
。
要一个接一个 table,您必须相应地更新 yPosition
和 page
,例如然后使用 table.draw()
的 return 值和 table
的状态,即替换
table.draw();
来自
yPosition = table.draw();
page = table.getCurrentPage();
我想按行和列显示记录集。我正在获取输出,但问题是,它正在重叠。我应该修改循环有人可以建议吗?
ArrayList<ResultRecord> Records = new ArrayList<ResultRecord>(MainRestClient.fetchResultRecords(this.savedMainLog));
for(j=0; j<Records.size(); j++)
{
Row<PDPage> row4 = table.createRow(100.0f);
Cell<PDPage> cell10 = row4.createCell(15.0f, temp.getNumber());
Cell<PDPage> cell11 = row4.createCell(45.0f, temp.getDescription());
Cell<PDPage> cell12 = row4.createCell(15.0f, temp.getStatus());
Cell<PDPage> cell13 = row4.createCell(25.0f, temp.getRemarks());
}
以下是打开 PDF 文件的完整代码。我想在相应单元格的 row4 中检索记录集。但是一个写在另一个上面。 预期输出: IT 应该一个一个地显示在另一个下方。 是重叠的原因,是因为定义行为row4.
try {
//table.draw();
cell.setFontSize(12);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
首先,你应该弄清楚你使用的table绘图库。 PDFBox 只是底层的 PDF 库。考虑到使用的 类 我会假设你在它上面使用 Boxable。
此外,所有 table 相互重叠打印的原因是您在同一页上的相同位置开始每个 table,您使用
BaseTable table = new BaseTable(yPosition, yStartNewPage,
bottomMargin, tableWidth, margin, document, page, true, drawContent);
无需更改 yPosition
或 page
。
要一个接一个 table,您必须相应地更新 yPosition
和 page
,例如然后使用 table.draw()
的 return 值和 table
的状态,即替换
table.draw();
来自
yPosition = table.draw();
page = table.getCurrentPage();