Chapter 16. PDF streams

 

This chapter covers

  • Image and font streams
  • Adding and extracting file attachments
  • Creating portable collections
  • Integrating rich media

We’ve arrived at the final chapter of part 4. In this part, we’re turning PDF files inside out. In chapter 13, we explored the file structure and discussed the different objects. We focused on the content stream of pages in chapters 14 and 15.

In this chapter, we’ll continue working with streams: we’ll look at image and font streams, and you’ll find out how to add streams containing other files as attachments, and how to organize these files in a portable collection. We’ll finish this chapter with some really cool examples of adding multimedia annotations to a document and integrating a Flash application into a PDF document.

16.1. Finding and replacing image and font streams

When you create an image using the Image class, or a font using the Font or BaseFont class, you don’t have to worry about the way these objects are stored in the finished document. For example, when you use a standard Type 1 font, iText will add a font dictionary to the PDF file. When you use a font that is embedded, the font dictionary will also refer to a stream with a full or partial font program that is copied into the PDF file.

16.2. Embedding files into a PDF

16.3. Integrating rich media

16.4. Summary