iText 5

Working with the ColumnText object (iText 5)

In this section, you’ll learn about the different ways to use the ColumnText object: text mode if you only use Chunks and Phrases, composite mode if you want to use other types of high-level objects as well. In listing 3.13, you wrote a showMovieInfo() method. If a screening was reserved for the press, you marked […]

Creating reusable content (iText 5)

In this section, we’ll discuss two types of reusable content: Images and PdfTemplate objects. Do you remember section 2.3.3 about the Image object? In an FAQ, I explained that you can add the same image to a document more than once, but that you should reuse the same Image instance if you want to avoid […]

Constructing tables (iText 5)

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. […]

Changing the properties of a cell Part 1 (iText 5)

PdfPCell extends Rectangle, inheriting a plethora of methods to change the way borders are drawn and backgrounds are painted. We’ll discuss these methods later on. First, we’ll focus on the content of a PdfPCell. Internally, PdfPCell content is kept inside a ColumnText object. The mechanics of a PdfPCell are easy to understand if you know […]

Changing the properties of a cell Part 2 (iText 5)

PdfPCell in composite mode Text mode is meant for Chunk and Phrase objects. As soon as you need Paragraphs, Lists, or Images, you have to work in composite mode. There’s a huge difference between In the first code line, the Paragraph is treated in text mode: Paragraph-specific properties, such as the leading and the alignment, […]

Dealing with large tables (iText 5)

The table in figure 4.11 has a header with a date. If you download the example and generate the PDF on your own computer, you’ll see that the table with all the movies spans more than one page for most of the days. The table is nicely split, but unfortunately the header isn’t repeated. In […]

Adding a table at an absolute position (iText 5)

In topic 2, you created high-level objects, and you let iText decide where they had to be put on the page. In topic 3, you learned about writing to the direct content, and you discovered how to combine high-level objects with low-level access using the ColumnText object. Up until now, you’ve used the PdfPTable class […]

Decorating tables using table and cell events (iText 5)

Two methods that are present in the API documentation for PdfPTable and PdfPCell were overlooked in topic 4: PdfPTable.setTableEvent() and PdfPCell.setCell-Event(). The former method expects an implementation of the PdfPTableEvent interface as its parameter; the latter expects a PdfPCellEvent implementation. These interfaces can be used to define a custom layout for tables and cells; for […]

Events for basic building blocks (iText 5)

When you add a basic building block to a Document instance, it’s translated into PDF syntax and written to a PDF file by a PdfWriter object. In this process, there’s an important class you’ll hardly ever need to address directly: PdfDocument. This class is responsible for examining the high-level objects. It’s the invisible rope tying […]

Overview of the page boundaries (iText 5)

Up until now, you’ve defined the page size using a Rectangle as the value of one of the five different page boundaries that can exist for a page in a PDF document. You’ll learn more about these boundaries in this section, and you’ll work through an example that demonstrates the difference between the two most […]