我正在使用iText创建一个带有表格的PDF。表头有90度旋转的文本,我使用CellEvent添加(下面的代码)。这个效果很好,除非表格跨越多个页面,旋转的单元格标题文本从页面顶部流出。
我试过设置cell.setFixedHeight(100),但它似乎不影响单元格。我也尝试了this solution,但是我无法让单元格显示带有文本的结果图像。
@Override
public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) {
PdfContentByte canvas = canvases[PdfPTable.TEXTCANVAS];
try {
canvas.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.WINANSI, false), this.fontSize);
} catch (DocumentException | IOException e) {
e.printStackTrace();
}
if (this.alignment == PdfPCell.ALIGN_CENTER) {
this.left = ((position.getRight() - position.getLeft()) / 2 );
}
else if (this.alignment == PdfPCell.ALIGN_MIDDLE) {
this.top = ((position.getTop() - position.getBottom())