【发布时间】:2019-08-31 15:51:06
【问题描述】:
我正在使用 PDFBox v2 和 boxable,我需要生成一个内部有 2 行的单元格。
我试图像wiki 解释的那样,但在我的应用程序单元格内容中按字面意思打印。
生成内表的代码为:
activeRow.createCell(100f, "<table><tr><td> R1 </td></tr><tr><td> R2 </td></tr></table>");
出了什么问题?
谢谢!
【问题讨论】:
我正在使用 PDFBox v2 和 boxable,我需要生成一个内部有 2 行的单元格。
我试图像wiki 解释的那样,但在我的应用程序单元格内容中按字面意思打印。
生成内表的代码为:
activeRow.createCell(100f, "<table><tr><td> R1 </td></tr><tr><td> R2 </td></tr></table>");
出了什么问题?
谢谢!
【问题讨论】:
我回答我自己的问题。
问题是致电createCell()。创建内表的正确方法是createTableCell()。
【讨论】:
float margin = 80;
// starting y position is whole page height subtracted by top and bottom margin
float yStartNewPage = page.getMediaBox().getHeight() - (2 * margin);
// we want table across whole page width (subtracted by left and right margin ofcourse)
float tableWidth = page.getMediaBox().getWidth() - (2 * margin);
boolean drawContent = true;
float yStart = yStartNewPage;
float bottomMargin = 70;
float yPosition = 550;
cell = row.createTableCell((100), "", document, page, yPosition , bottomMargin, margin);
在表格内创建简单的表格单元格
【讨论】: