From 78894f99ac80c6dcbf4610d73771680c6c8e9a86 Mon Sep 17 00:00:00 2001
From: Brian Manning <brian@xaoc.org>
Date: Fri, 6 May 2016 11:30:41 -0700
Subject: [PATCH] table_demo: added file

---
 table_demo | 136 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 136 insertions(+)
 create mode 100755 table_demo

diff --git a/table_demo b/table_demo
new file mode 100755
index 0000000..f8d1c99
--- /dev/null
+++ b/table_demo
@@ -0,0 +1,136 @@
+#!/usr/bin/env php
+
+<?php
+/**
+ * FILENAME:
+ * pdflib_demo
+ *
+ * DESCRIPTION:
+ * Demonstration of the pdflib PHP Library for generating PDF files
+ *
+ */
+
+/**
+ Links:
+  - https://www.pdflib.com/developer/technical-documentation/manuals/
+  - https://www.pdflib.com/pdflib-cookbook/browse-all-topics/
+  - https://www.pdflib.com/pdflib-cookbook/graphics/layers-and-bookmarks/php-layers-and-bookmarks/
+  - https://www.pdflib.com/pdflib-cookbook/text-output/create-interactive-index/php-create-interactive-index/
+  - https://www.pdflib.com/pdflib-cookbook/general-programming/starter-basic/php-general-progamming-issues/
+  - https://www.pdflib.com/en/pdflib-cookbook/block-handling-and-pps/linked-textblocks/php-linked-textblocks/
+  - https://www.pdflib.com/pdflib-cookbook/interactive-elements/link-annotations/php-link-annotations/
+  - https://www.pdflib.com/pdflib-cookbook/text-output/footnotes-in-text/footnotes-in-text/
+  - https://www.pdflib.com/fileadmin/pdflib/Cookbook/pdf/footnotes_in_text.pdf
+  - https://www.pdflib.com/pdflib-cookbook/pdf-import/import-in-reverse-order/php-import-in-reverse-order/
+
+*/
+
+// set a default timezone
+date_default_timezone_set("America/Los_Angeles");
+
+//require_once('tcpdf_include.php');
+$outfile = __DIR__ . '/table_output.pdf';
+
+// page placement defaults
+$pageTopYPortrait = 750;
+$pageTopYLandscape = 570;
+
+
+// wrap PDFlib usage in a try{} block
+try {
+   $pdf = new PDFlib();
+
+   // set up some PDFlib options
+   $pdf->set_option("errorpolicy=return");
+   $pdf->set_option("stringformat=utf8");
+
+   if ($pdf->begin_document($outfile, "") == 0)
+      throw new Exception("Error: " . $pdf->get_errmsg());
+
+   // set up the document metadata info
+   $pdf->set_info('Creator', 'IODP Science Support Office');
+   $pdf->set_info('Author', 'IODP Science Support Office');
+   $pdf->set_info('Title', 'Demo of TCPDF for generating IODP Proposals');
+   $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, '');
+
+   // 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=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);
+   $pdf->fit_textline("Привет! Этот немного текста.", 20, 690, $textOpts);
+
+   // END PAGE 1
+   $pdf->end_page_ext('');
+
+   // START PAGE 2
+   //$pdf->begin_page_ext(612, 792, '');
+   $ssfPDF = $pdf->open_pdi_document(__DIR__ . "/site_summary_figure.pdf", '');
+   if ($ssfPDF == 0)
+      throw new Exception("Error: " . $p->get_errmsg());
+
+   $ssfPage = $pdf->open_pdi_page($ssfPDF, 1, '');
+   $ssfWidth = $pdf->pcos_get_number($ssfPDF, "pages[0]/width");
+   $ssfHeight = $pdf->pcos_get_number($ssfPDF, "pages[0]/height");
+   //print "Page width/height: $ssfWidth x $ssfHeight\n";
+
+   $pdf->begin_page_ext($ssfWidth, $ssfHeight, '');
+
+   $pdf->fit_pdi_page($ssfPage, 0, 0, '');
+   $pdf->close_pdi_page($ssfPage);
+   $pdf->close_pdi_document($ssfPDF);
+
+   // write some text on to the page
+   $action = $pdf->create_action("GoTo", "destination={page=1}");
+   $pdf->fit_textline("Back to Top", 20, $ssfHeight - 30,
+      $textOpts . " underline=true matchbox={name=to_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
+   $pdf->end_page_ext('');
+
+   // START PAGE 3
+   $pdf->begin_page_ext(612, 792, '');
+
+   // END PAGE 3
+   $pdf->end_page_ext('');
+
+   // close the document
+   $pdf->end_document('');
+
+} catch (PDFlibException $e) {
+   die("PDFlib exception occurred\n"
+      . "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": "
+      . $e->get_errmsg() . "\n");
+} catch (Exception $e) {
+   die($e);
+}
+
+// vim: expandtab filetype=php shiftwidth=3 tabstop=3
-- 
1.9.1