How to draw a borderless table in iTextSharp?

It appears as though the PDfPCell class does have a border property on it but not the PdfPTable class. Is there some property on the PdfPTable class to set the borders of all its contained cells in

It appears as though the PDfPCell class does have a border property on it but not the PdfPTable class.

Is there some property on the PdfPTable class to set the borders of all its contained cells in one statement?

Posted on StackOverflow on Jun 3, 2014 by Water Cooler v2

Borders are defined at the level of the cell, not at the level of the table. Hence: if you want to remove the borders of the table, you need to remove the borders of each cell. Note that there is no PdfPCell class in iText 7 anymore, you should use Cell instead.

By default, each cell has a border. You can change this default behavior by changing the border of each cell. For instance: if you create Cell objects, you use:

cell.setBorder(Border.NO_BORDER);

In case the cells are created internally, you need to change that property at the level of the table (default cell):

table.setBorder(Border.NO_BORDER);

For special borders, for instance borders with rounded corners or a single border for the whole table, or double borders, you can use either cell events or table events, or a combination of both.

Click this link if you want to see how to answer this question in iText 5.



Ready to use iText?

Try our iText 7 Library and add-ons FREE for 30 days. Test your proof of concept, and see if our solution is right for you.

Get my FREE trial
Contact

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now