17.05.2014 Views

PDFlib 8 Windows COM/.NET Tutorial

PDFlib 8 Windows COM/.NET Tutorial

PDFlib 8 Windows COM/.NET Tutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3.6 Interactive Elements<br />

Cookbook Code samples for creating interactive elements can be found in the interactive category of<br />

the <strong>PDFlib</strong> Cookbook.<br />

3.6.1 Links, Bookmarks, and Annotations<br />

This section explains how to create interactive elements such as bookmarks, form<br />

fields, and annotations. Figure 3.1 shows the resulting document with all interactive elements<br />

that we will create in this section. The document contains the following interactive<br />

elements:<br />

> At the top right there is an invisible Web link to www.kraxi.com at the text<br />

www.kraxi.com. Clicking this area will bring up the corresponding Web page.<br />

> A gray form field of type text is located below the Web link. Using JavaScript code it<br />

will automatically be filled with the current date.<br />

> The red pushpin contains an annotation with an attachment. Clicking it will open<br />

the attached file.<br />

> At the bottom left there is a form field of type button with a printer symbol. Clicking<br />

this button will execute Acrobat’s menu item File, Print.<br />

> The navigation page contains the bookmark »Our Paper Planes Catalog«. Clicking<br />

this bookmark will bring up a page of another PDF document.<br />

In the next paragraphs we will show in detail how to create these interactive elements<br />

with <strong>PDFlib</strong>.<br />

Web link. Let’s start with a link to the Web site www.kraxi.com. This is accomplished in<br />

three steps. First, we fit the text on which the Web link should work. Using the matchbox<br />

option with name=kraxi we specify the rectangle of the text’s fitbox for further reference.<br />

Second, we create an action of type URI (in Acrobat: Open a web link). This will provide<br />

us with an action handle which subsequently can be assigned to one or more interactive<br />

elements.<br />

Third, we create the actual link. A link in PDF is an annotation of type Link. The action<br />

option for the link contains the event name activate which will trigger the action, plus<br />

the act handle created above for the action itself. By default the link will be displayed<br />

Fig. 3.1<br />

Document with interactive<br />

elements<br />

3.6 Interactive Elements 87

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!