2016-06-29 3 views
0

私は問題なくいくつかのPdfPTableを作成しましたが、今は何が間違っているのか分かりません。 4行目は表示されません。iTextでPdfPCellを追加するPdfPtable doesnt work do

table = new PdfPTable(4); 
    table.setSpacingBefore(10); 
    columnWidths = new float[] {60,10,10,10}; 
    table.setWidths(columnWidths); 

    PdfPCell cellFooter = new PdfPCell(new Phrase("Rows One", ARIAL_12_BOLD)); 
    table.addCell(cellFooter); 
    for(int k=0; k<3; k++){ 
     table.addCell(""); 
    } 

    cellFooter = new PdfPCell(new Phrase("Row Two", ARIAL_12_BOLD)); 
    table.addCell(cellFooter); 

    for(int k=0; k<3; k++){ 
     table.addCell(""); 
    } 

    cellFooter = new PdfPCell(new Phrase("Row Three", ARIAL_12_BOLD)); 
    cellFooter.setColspan(4); 
    table.addCell(cellFooter); 

    // Row Four not displayed 
    for(int k=0; k<4; k++){ 
     table.addCell(""); 
    } 

答えて

0

回答するには、私にお聞かせください。高さの何ピクセルが空の文字列ですか?

これを回避する最も簡単な方法は、何かを追加することです。

table.addCell(" "); 

しかし、あなたはあなたが明示的に空のセルのフォント(したがって高さ)を設定したい場合がありますので、他の場所で高さが異なる場合がありますフォントサイズを変更している場合:あなただけを使用することができるはずです。

table.addCell(new Phrase(" ", ARIAL_12_BOLD)); 

セルの高さを明示的に定義することもできますが、通常これが最も簡単です。

関連する問題