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.

with a thin black border. Initially this is convenient for precise positioning, but we disabled<br />

the border with linewidth=0.<br />

normalfont = p.load_font("Helvetica", "unicode", "");<br />

p.begin_page_ext(pagewidth, pageheight, "topdown");<br />

/* place the text line "Kraxi Systems, Inc." using a matchbox */<br />

String optlist =<br />

"font=" + normalfont + " fontsize=8 position={left top} " +<br />

"matchbox={name=kraxi} fillcolor={rgb 0 0 1} underline";<br />

p.fit_textline("Kraxi Systems, Inc.", 2, 20, optlist);<br />

/* create URI action */<br />

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

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

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

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

/* 0 rectangle coordinates will be replaced with matchbox coordinates */<br />

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

p.end_page_ext("");<br />

For an example of creating a Web link on an image or on parts of a textflow, see Section<br />

8.4, »Matchboxes«, page 243.<br />

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

Bookmark for jumping to another file. Now let’s create the bookmark »Our Paper<br />

Planes Catalog« which jumps to another PDF file called paper_planes_catalog.pdf. First<br />

we create an action of Type GoToR. In the option list for this action we define the name<br />

of the target document with the filename option; the destination option specifies a certain<br />

part of the page which will be enlarged. More precisely, the document will be displayed<br />

on the second page (page 2) with a fixed view (type fixed), where the middle of the<br />

page is visible (left 50 top 200) and the zoom factor is 200% (zoom 2):<br />

String optlist =<br />

"filename=paper_planes_catalog.pdf " +<br />

"destination={page 2 type fixed left 50 top 200 zoom 2}";<br />

goto_action = p.create_action("GoToR", optlist);<br />

In the next step we create the actual bookmark. The action option for the bookmark contains<br />

the activate event which will trigger the action, plus the goto_action handle created<br />

above for the desired action. The option fontstyle bold specifies bold text, and textcolor<br />

{rgb 0 0 1} makes the bookmark blue. The bookmark text »Our Paper Planes Catalog« is<br />

provided as a function parameter:<br />

String optlist =<br />

"action={activate " + goto_action + "} fontstyle=bold textcolor={rgb 0 0 1}";<br />

catalog_bookmark = p.create_bookmark("Our Paper Planes Catalog", optlist);<br />

Clicking the bookmark will display the specified part of the page in the target document.<br />

88 Chapter 3: Creating PDF Documents (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!