Chapter 6. Working with existing PDFs

 

This chapter covers

  • Importing pages from existing PDF documents
  • Adding content to existing PDF documents and filling forms
  • Copying pages from existing PDF documents

When I wrote the first book about iText, the publisher didn’t like the subtitle “Creating and Manipulating PDF.” He didn’t like the word manipulating because of some of its pejorative meanings. If you consult the dictionary on Yahoo! education, you’ll find the following definitions:

  • To influence or manage shrewdly or deviously
  • To tamper with or falsify for personal gain

Obviously, that’s not what the book is about. The publisher suggested “Creating and Editing PDF” as a better subtitle. I explained that PDF isn’t a document format well suited for editing. PDF is an end product. It’s a display format. It’s not a word processing format.

In a word processing format, the content is distributed over different pages when you open the document in an application, not earlier. This has some disadvantages: if you open the same document in different applications, you can end up with a different page count. The same text snippet can be on page X when looked at in Microsoft Word, and on page Y when viewed in Open Office. That’s exactly the kind of problem you want to avoid by choosing PDF.

6.1. Accessing an existing PDF with PdfReader

6.2. Copying pages from existing PDF documents

6.3. Adding content with PdfStamper

6.4. Copying pages with PdfCopy

6.5. Summary

sitemap