Chapter 4. Organizing content in tables

 

This chapter covers

  • Constructing a PdfPTable object
  • Exploring the properties of a PdfPCell object
  • Adding tables to the Document object

iText has existed for more than ten years now. If you were to ask me which objects have been the most important in the iText-related projects I’ve done in all those years, I wouldn’t have to think twice about the answer. Most of my assignments have consisted of creating reports that render the content of a database to a PDF document. This content had to be organized in tabular form. This can be achieved using two classes that are important enough to be the focus of an entire chapter: PdfPTable and PdfPCell.

We’ll start with simple examples, then move on to more complex tables using the data from the movie database.

4.1. Constructing tables

iText’s table functionality has evolved from a very low-level class in the early versions of iText to the twin classes Table and PdfTable in iText 0.30 (2000). These classes were useful, but they had some flaws. It was hard to fine-tune them due to design decisions made by the iText developers; that is, by me. Developers wanted to define how to split the table upon a page break, to control the way borders are drawn, and so on. The PdfPTable class, introduced by the codeveloper of iText, Paulo Soares, solved this problem.

4.2. Changing the properties of a cell

4.3. Dealing with large tables

4.4. Adding a table at an absolute position

4.5. Summary

sitemap