iText 5

Adding page events to PdfWriter (iText 5)

After the intermezzo about page boundaries, containing some self-glorifying examples, it’s time to return to the real topic of this topic: page events. We have already discussed seven methods of the PdfPageEvent interface; four more methods involving the document and its pages remain: ■ onOpenDocument() —Triggered when a document is opened. This is a good […]

Accessing an existing PDF with PdfReader (iText 5)

First, we’ll look at how you can retrieve information about the document you’re going to manipulate. For instance, how many pages does the original document have? Which page size is used? All of this is done with a PdfReader object. Retrieving information about the document and its pages In this first example, we’ll inspect some […]

Copying pages from existing PDF documents (iText 5)

You probably remember the Superman PDF from topic 5. The Hero example imported a plain text file containing PDF syntax into the direct content. I explained that this wasn’t standard practice. If you want to reuse existing content, it’s dangerous to copy and paste PDF syntax like I did in listing 5.14. There are safer […]

Adding content with PdfStamper Part 1 (iText 5)

Up until now, we’ve created new documents using the five steps in the iText document-creation process. In this topic we’ll add content to an existing document using PdfStamper. PdfStamper uses a different mechanism, as demonstrated in the manipulateWith-Stamper() method. Listing 6.11 SelectPages.java You’ve already seen part of this example in listing 6.3. It’s an example […]

Adding content with PdfStamper Part 2 (iText 5)

Filling out a PDF form There are different flavors of forms in PDF. We’ll discuss the details in topic 8, where we’ll create forms using iText. For now, we’re going to use another tool to create an interactive PDF form. CREATING A FORM WITH OPEN OFFICE Figure 6.10 shows how you can use Open Office […]

Copying pages with PdfCopy (iText 5)

In the previous section, each PdfStamper object was associated with one and only one PdfReader object. As soon as you want to assemble pages from more than one document, you should use another PDF manipulation class: PdfCopy. PdfCopy extends PdfWriter, and you’ll immediately recognize the five steps in the PDF creation process: Listing 6.20 SelectPages.java […]

Introducing actions Part 1 (iText 5)

If you’re reading this topic from beginning to end, actions shouldn’t be new to you. You created documents containing actions in topic 2, but we didn’t call them actions; instead we talked about remote and local goto links. In this section, you’ll add go to actions using the PdfAction class, and you’ll also learn how […]

Introducing actions Part 2 (iText 5)

JavaScript in PDF documents JavaScript is a scripting language that is primarily used to add client-side functionality to an HTML page and to create dynamic websites. It allows programmatic access to objects within the web browser. JavaScript is also available in PDF viewers such as Adobe Reader. There’s a JavaScript API for PDF documents that […]

Adding bookmarks (iText 5)

In PDF language, we often use the terms outline tree or outlines as synonyms for bookmarks. In topic 2, you created bookmarks automatically by using topic and Section objects. The result was nice, but you can do better if you create the outline using PdfOutline objects. The PdfOutline class offers much more functionality, and you […]

Creating annotations (iText 5)

According to Merriam-Webster’s Online Dictionary, an annotation is a note added by way of comment or explanation. But an annotation in a PDF can be much more. It can be a movie or a sound that will be played in the document. It can be a field with a value that changes depending on other […]