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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

esult = p.fit_textflow(tflow, 0, 0, 50, 70, "fitmethod=auto");<br />

if (!result.equals("_stop"))<br />

{ /* ... */ }<br />

/* create URI action */<br />

optlist = "url={http://www.kraxi.com}";<br />

act = p.create_action("URI", optlist);<br />

/* create Link annotation on matchbox "kraxi" */<br />

optlist = "action={activate " + act + "} linewidth=0 usematchbox={kraxi}";<br />

p.create_annotation(0, 0, 0, 0, "Link", optlist);<br />

Even if the text Kraxi Systems, Inc. spans several lines the appropriate number of link annotations<br />

will be created automatically with a single call to create_annotation( ). The result<br />

in shown in Figure 8.42.<br />

For information about<br />

Giant Wing Paper<br />

Planes see the Web<br />

site of Kraxi Systems,<br />

Inc.<br />

Fig. 8.42<br />

Add Weblinks to parts of a Textflow<br />

8.4.3 Matchboxes and Images<br />

Adding a Web link to an image. To add a Web link to the area covered by an image the<br />

image matchbox can be used. The code is similar to »Adding a Web link to the Textflow<br />

matchbox«, page 244, above. However, instead of placing the Textflow, fit the image using<br />

the following option list:<br />

String optlist = "boxsize={130 130} fitmethod=meet matchbox={name=kraxi}";<br />

p.fit_image(image, 10, 10, optlist);<br />

Cookbook A full code sample can be found in the Cookbook topic interactive/link_annotations.<br />

Drawing a frame around an image. In this example we want to use the image matchbox<br />

to draw a frame around the image. We completely fit the image into the supplied<br />

box while maintaining its proportions using fitmethod=meet. We use the matchbox option<br />

with the borderwidth suboption to draw a thick border around the image. The<br />

strokecolor suboption determines the border color, and the linecap and linejoin suboptions<br />

are used to round the corners.<br />

Cookbook A full code sample can be found in the Cookbook topic images/frame_around_image.<br />

The matchbox is always drawn before the image which means it would be partially hidden<br />

by the image. To avoid this we use the offset suboptions with 50 percent of the border<br />

width to enlarge the frame beyond the area covered by the image. Alternatively, we<br />

could increase the border width accordingly. Figure 8.43 shows the option list used with<br />

fit_image( ) to draw the frame.<br />

244 Chapter 8: Text and Table Formatting (Edition for <strong>COM</strong>, .<strong>NET</strong>, and REALbasic)

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

Saved successfully!

Ooh no, something went wrong!