cell.setHeight(cell.getTextHeight() + 0.5f);
重要的是选择cell.getTextHeight()
,然后添加您的值,如果您只输入12f之类的数字将无法使用
我根据https://github.com/dhorions/boxable/wiki的示例创建了BaseTable
float margin = 50;
float yStartNewPage = myPage.getMediaBox().getHeight() - (2 * margin);
float tableWidth = myPage.getMediaBox().getWidth() - (2 * margin);
boolean drawContent = true;
float yStart = yStartNewPage;
float bottomMargin = 70;
float yPosition = 550;
BaseTable table = new BaseTable(yPosition, yStartNewPage, bottomMargin, tableWidth, margin, mainDocument, myPage, true, drawContent);
Row<PDPage> headerRow = table.createRow(15f);
Cell<PDPage> cell = headerRow.createCell(100, "Header");
table.addHeaderRow(headerRow);
Row<PDPage> row = table.createRow(12);
cell = row.createCell(30, "Data 1");
cell = row.createCell(70, "Some value");
table.draw();
contentStream.close();
mainDocument.addPage(myPage);
mainDocument.save("testfile.pdf");
mainDocument.close();
表看起来不错
<<但是当我想像这样改变像元高度时>
cell.setHeight(5f);
内容未在单元格中绘制
我曾尝试更改行高,更改字体大小,但没有帮助。您知道如何解决吗?
我根据https://github.com/dhorions/boxable/wiki浮动边距= 50的示例创建了BaseTable; float yStartNewPage = myPage.getMediaBox()。getHeight()-(2 * margin); float ...
cell.setHeight(cell.getTextHeight() + 0.5f);
重要的是选择cell.getTextHeight()
,然后添加您的值,如果您只输入12f之类的数字将无法使用