簡體   English   中英

iText表中第一頁的最后一行不像在表格跨頁拆分時的所有其他行一樣在字體的基線處繪制邊框

[英]Last row on the first page in iText table isn't drawing border at baseline of the font like all the other rows when table is split across pages

下面有一個示例,該示例生成一個包含十行的表,最后一行占用兩行。 文檔高度比正確放置整個桌子所需的高度小兩點。 正如預期的那樣,第一頁的最后一行包含單詞“ Two”,“ Lines”部分在另一頁上繼續。 但是,生成的PDF會擴展最后一行以適合整個文檔(不包括頁邊距填充),而不是使用最后一行中的文本高度來確定其高度。 請注意,我使用table.setExtendLastRow(false, false)來保證不應該擴展該表,但是最后一行仍在擴展。 有什么想法如何阻止最后一行的擴展嗎?

FileOutputStream out = new FileOutputStream(new File("table.pdf"));
Document document = new Document(new Rectangle(612, 242));
PdfWriter.getInstance(document, out);

document.open();

PdfPTable table = new PdfPTable(1);
table.setWidthPercentage(100);
table.setSplitLate(false);
table.setSplitRows(true);
table.setExtendLastRow(false, false);

for (int i = 0; i < 10; i++) {
    PdfPCell cell;
    if (i == 9) {
        cell = new PdfPCell(new Phrase("Two\nLines"));
    }
    else {
        cell = new PdfPCell(new Phrase(Integer.toString(i)));
    }
    table.addCell(cell);
}

document.add(table);
document.close();

我上傳了一張我所看到的照片。 請注意,單詞“ Two”下的間距不同於行中所有其他數字下的間距。 它似乎延伸到頁邊距的底部。

第一頁最后一行的圖像未在字體的底部繪制

這是預期的行為,並且iText當前不支持這種極端情況。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM