Chapter 10. Brightening your document with color and images
This chapter covers
- Using color in PDF documents
- Introducing transparency
- Using images in PDF documents
You’ve already used color and images in previous chapters. You set the background and changed the font color of a Chunk using the BaseColor class in chapter 2. You used setColorFill() and setColorStroke() methods when you painted movie blocks on a calendar sheet in chapter 3. But that doesn’t mean we’ve talked about everything. One could write an entire book about color.
The same goes for images. We looked at the Image class in chapter 2, but there are many other classes involved when creating an Image object: Jpeg, GifImage, TiffImage, and so on. It would lead us too far astray to go into too much detail about color and images, but this chapter will help you if you need more color or image functionality than we covered in part 1.
Colors are defined using values, and these values are interpreted according to a color space. Color spaces are expressed as PDF dictionaries, and there are eleven different color spaces available in PDF. You can find a reference to these dictionaries in the resources entry of a PDF stream. This is explained in great detail in the PDF reference; but don’t worry, iText provides color classes that hide the complex theory.
The most common group of color spaces is the device color space family.