문제

I am trying to define the Padding of a serie of columns that will be pushed inside my PdfPTable...

this is my code:

PdfPTable table = new PdfPTable(6);
table.WidthPercentage = 100;
table.SetWidths(new float[]{25, 25, 16, 11, 11, 11});
table.DefaultCell.Padding = 3;

There are something wrong, because when the table is generated, it does not have padding in anywhere.

Thank you in advance.

도움이 되었습니까?

해결책

See this post from the creator of iText. The DefaultCell only gets used when calling AddCell with a string, phrase, image or another table. When you manually create a cell using New PdfPCell() then the defaults aren't used.

EDIT

Here's a sample factory method:

private static PdfPCell CreateCell() {
    var c = new PdfPCell();
    c.Padding = 5;
    return c;
}

You can also skip the factory method if you're only setting properties and use object initialization:

var c = new PdfPCell() { Padding = 5 };
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top