From 97614a87bf8e2a3afd38532be26ef7b83a36cb30 Mon Sep 17 00:00:00 2001 From: Brian Manning Date: Tue, 3 May 2016 17:20:31 -0700 Subject: [PATCH] pdflib_demo: added bookmarks; reused the $action variable everywhere --- pdflib_demo | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/pdflib_demo b/pdflib_demo index 610a68a..b9257d7 100755 --- a/pdflib_demo +++ b/pdflib_demo @@ -52,16 +52,33 @@ try { $pdf->set_info('Subject', 'IODP Proposals'); $pdf->set_info('Keywords', 'IODP proposal ocean drilling core expedition'); + $textOpts = "fontname={Helvetica} embedding fontsize=20 " + . "encoding=unicode "; + // START PAGE 1 $pdf->begin_page_ext(612, 792, ''); - $textOpts = "fontname={Helvetica} embedding fontsize=20 " - . "encoding=unicode "; + // create bookmarks first thing + $action = $pdf->create_action("GoTo", "destination={page=1}"); + $pdf->create_bookmark("Page 1", " action={activate= " . $action . "}"); + // action + $action = $pdf->create_action("GoTo", "destination={page=2}"); + // bookmark + $pdf->create_bookmark("Page 2", " action={activate= " . $action . "}"); + + + // text/image $pdf->fit_textline("Jump to SSF for SHACK-10A", 20, 750, - $textOpts); # . " underline=true matchbox={name=first_page}"); + $textOpts . " underline=true matchbox={name=to_second_page}"); + // annotation; reuse the "page 2" action above + $optlist = "action={activate " . $action . "} linewidth=0 " . + "usematchbox={to_second_page}"; + $pdf->create_annotation(0, 0, 0, 0, "Link", $optlist); + + // the rest of the text on page 1 $pdf->fit_textline("This is some text on the first page; ", 20, 720, - $textOpts); # . " matchbox={name=first_page}"); + $textOpts); $pdf->fit_textline("Привет! Этот немного текста.", 20, 690, $textOpts); // END PAGE 1 @@ -88,15 +105,13 @@ try { // for landscape mode... //$pdf->fit_textline("Back to Top", 20, 570, //$linkOpts = linkAttribs(1, 750); - #$actionList = "destination={page=1 type=fixed left=0 top=750}"; - $actionList = "destination={page=1}"; - $action = $pdf->create_action("GoTo", $actionList); + $action = $pdf->create_action("GoTo", "destination={page=1}"); $pdf->fit_textline("Back to Top", 20, $ssfHeight - 30, - $textOpts . " underline=true matchbox={name=first_page}"); + $textOpts . " underline=true matchbox={name=to_first_page}"); - // FIXME call create_annotation here - $optlist = "action={activate " . $action . "} linewidth=1 " . - "usematchbox={first_page}"; + // call create_annotation here + $optlist = "action={activate " . $action . "} linewidth=0 " . + "usematchbox={to_first_page}"; $pdf->create_annotation(0, 0, 0, 0, "Link", $optlist); // END PAGE 2 @@ -104,7 +119,6 @@ try { // close the document $pdf->end_document(''); - } catch (PDFlibException $e) { -- 1.9.1