0

What is the 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 it.

The documentation for the .NET library is lacking. The Java one is still documented but again not that well. I usually look up from the Java one because the two API's are symmetrical. But I still don't understand the meaning of this property.

Water Cooler v2
  • 32,724
  • 54
  • 166
  • 336

1 Answers1

2

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.)

This is explained in Chapter 4 of my book "iText in Action - Second Edition".

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165