From 9d13742da44d526a8c4345f94271120cbce777a2 Mon Sep 17 00:00:00 2001 From: Brian Manning <brian@xaoc.org> Date: Tue, 3 May 2016 10:09:06 -0700 Subject: [PATCH] pdflib_demo: added code that should produce links - Switched back to the portrait SSF from P771 - Added a function `linkAttribs()` that would create the text for setting up attributes for links --- pdflib_demo | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pdflib_demo b/pdflib_demo index 64bcc08..ed478a5 100755 --- a/pdflib_demo +++ b/pdflib_demo @@ -29,6 +29,11 @@ date_default_timezone_set("America/Los_Angeles"); //require_once('tcpdf_include.php'); $outfile = __DIR__ . '/output.pdf'; +// page placement defaults +$pageTopYPortrait = 750; +$pageTopYLandscape = 570; + + // wrap PDFlib usage in a try{} block try { $pdf = new PDFlib(); @@ -79,8 +84,13 @@ try { $pdf->close_pdi_document($ssfPDF); // write some text on to the page - $pdf->fit_textline("Back to Top", 20, 570, - $textOpts . " underline=true"); + // for landscape mode... + //$pdf->fit_textline("Back to Top", 20, 570, + //$linkOpts = linkAttribs(1, 750); + $optList = "destination={page=1 type=fixed left=0 top=750}"; + $action = $p->create_action("GoTo", $optList); + print_r($linkOpts); + $pdf->fit_textline("Back to Top", 20, 750, $linkOpts); // END PAGE 2 $pdf->end_page_ext(''); @@ -102,6 +112,11 @@ catch (Exception $e) { $p = 0; +function linkAttribs($pageNum = 1, $pageY = 750) { + return "destination={page={$pageNum} type=fixed left=0 top={$pageY}}" + . " underline=true"; +} + /* // write out the contents of the first page $pdf->AddPage(); -- 1.9.1