What is the PdfPTable.DefaultCell property used for?

别等时光非礼了梦想. 提交于 2019-12-18 09:49:28

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/24006618/what-is-the-pdfptable-defaultcell-property-used-for

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!