ITextSharp 4.1.6。PDF 表 - 各セルの上部にある空白を削除するにはどうすればよいですか?[パディングとリーディングはすでに 0 に設定されています]

StackOverflow https://stackoverflow.com//questions/9672046

  •  12-12-2019
  •  | 
  •  

質問

ITextSharp のテーブルに問題があります。セルを上下にパディングせずに、セルを互いに近づけて配置したいと考えています。

セルのパディングと先頭を 0 に設定しましたが、空白はまだ残ります。

See the screen

誰か空白を削除する方法を知っていますか?

編集:

ディランからの迅速な回答のおかげで、私は問題を解決することができました。誰かが同様の問題に遭遇した場合のソーススニペットは次のとおりです

        Document document = new Document(PageSize.A4, 5, 5, 10, 10);
        using (FileStream fs = new FileStream("C:\\Users\\brum\\Desktop\\untitled.pdf", FileMode.Create))
        {
            iTextSharp.text.pdf.PdfWriter.GetInstance(document, fs);
            document.Open();
            PdfPTable table = new PdfPTable(2);
            PdfPCell cell = new PdfPCell(new Phrase("Spanning 2 cols"));

            cell.Colspan = 2;
            cell.HorizontalAlignment = 1;
            cell.Padding = 0f;
            cell.UseAscender = true;
            table.AddCell(cell);

            table.AddCell("Next row 1");
            table.AddCell("Next row 2");

            document.Add(table);
            document.Close();
        }

cell.UseAscender = true; // This is the line that did the trick for me

役に立ちましたか?

解決

上部のパディングを小さい値または負の値に設定します。別のオプションはPdfPCell.setUseAscender().

元:

cell.setPaddingTop(0f);  // No padding on top cell

または

cell.UseAscender = true;

持っているコードを貼り付けてください。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top