gpt4 book ai didi

java - 表中的值被覆盖 -PDFbox

转载 作者:行者123 更新时间:2023-12-02 03:01:21 24 4
gpt4 key购买 nike

我想按行和列显示记录集。我正在获得输出,但问题是,它正在重叠。我应该修改循环吗?有人可以建议吗?

 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 文件的完整代码。我想检索相应单元格中第 4 行中的记录集。但上面写的是一个。预期输出:IT 应将一个显示在另一个下方。是重叠的原因吗,是不是因为将行定义为row4

 try {
//table.draw();

cell.setFontSize(12);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}

最佳答案

首先,你应该明确一下你所使用的表格绘图库。 PDFBox 只是底层 PDF 库。考虑到所使用的类,我假设您在其之上使用 Boxable。

此外,所有表格都相互打印的原因是您在同一页面上的相同位置开始每个表格,您使用

BaseTable table = new BaseTable(yPosition, yStartNewPage,
bottomMargin, tableWidth, margin, document, page, true, drawContent);

无需更改yPositionpage

要依次获取一张 table ,您必须相应地更新 yPositionpage,例如通过使用 table.draw() 的返回值和 table 的状态,即替换

table.draw();

yPosition = table.draw();
page = table.getCurrentPage();

关于java - 表中的值被覆盖 -PDFbox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61402920/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com