iText pdf library
Website search

What is the PdfPTable.DefaultCell property used for?

The Java documentation for PdfPTable.getDefaultCell() reads:

Gets the default PdfPCell that will be used as reference for all the addCell methods except addCell(PdfPCell).

I don't understand this.

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

When creating a PdfPTable, you add cells.

One way is to create a PdfPCell object and to add that cell with the addCell() method.

Another way is to use a short-cut: you don't create a PdfPCell, but you add a String or a Phrase to the table with the addCell() method. In this case, a PdfPCell is created internally using default properties. You can change the default properties by changing the properties of the default cell. The default cell is obtained using the getDefaultCell() method.

This is what the Javadoc information is about: this default PdfPCell will be used as reference for all the addCell() methods except addCell(PdfPCell). (Because when adding a PdfPCell, the properties of that PdfPCell will be used, not the properties of the default cell.)

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

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