Although I upvoted the answer by Martijn, I want to add a clarification.
Only cells have borders in iText; tables don't have a border. Martijn's suggestion to set the border of the default cell to NO_BORDER
is correct:
table.DefaultCell.Border = Rectangle.NO_BORDER;
But it won't work for the code snippet provided in the question. The properties of the default cell are only used if iText needs to create a PdfPCell
instance implicitly (for instance: if you use the addCell()
method passing a Phrase
as parameter).
In the code snippet provided by @Brown_Dynamite, the PdfPCell
objects are created explicitly. This means that you need to set the border of each of these cells to NO_BORDER
.
Usually, I write a factory class to create cells. That way, I can significantly reduce the amount of code in the class that creates the table.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…