Commit aada7532c9d2a907c4bb6e45c1b89af165c4d3d5

Authored by Brian Manning
1 parent 3f047791af

table_demo: changed output filename

Showing 1 changed file with 1 additions and 1 deletions Inline Diff

#!/usr/bin/env php 1 1 #!/usr/bin/env php
2 2
<?php 3 3 <?php
/** 4 4 /**
* FILENAME: 5 5 * FILENAME:
* pdflib_demo 6 6 * pdflib_demo
* 7 7 *
* DESCRIPTION: 8 8 * DESCRIPTION:
* Demonstration of the pdflib PHP Library for generating PDF files 9 9 * Demonstration of the pdflib PHP Library for generating PDF files
* 10 10 *
*/ 11 11 */
12 12
/** 13 13 /**
Links: 14 14 Links:
- https://www.pdflib.com/developer/technical-documentation/manuals/ 15 15 - https://www.pdflib.com/developer/technical-documentation/manuals/
- https://www.pdflib.com/pdflib-cookbook/browse-all-topics/ 16 16 - https://www.pdflib.com/pdflib-cookbook/browse-all-topics/
- https://www.pdflib.com/pdflib-cookbook/graphics/layers-and-bookmarks/php-layers-and-bookmarks/ 17 17 - 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/ 18 18 - 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/ 19 19 - 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/ 20 20 - 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/ 21 21 - 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/ 22 22 - 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 23 23 - 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/ 24 24 - https://www.pdflib.com/pdflib-cookbook/pdf-import/import-in-reverse-order/php-import-in-reverse-order/
25 25
*/ 26 26 */
27 27
// set a default timezone 28 28 // set a default timezone
date_default_timezone_set("America/Los_Angeles"); 29 29 date_default_timezone_set("America/Los_Angeles");
30 30
//require_once('tcpdf_include.php'); 31 31 //require_once('tcpdf_include.php');
$outfile = __DIR__ . '/table_output.pdf'; 32 32 $outfile = __DIR__ . '/pdflib_table_output.pdf';
33 33
// page placement defaults 34 34 // page placement defaults
$pageTopYPortrait = 750; 35 35 $pageTopYPortrait = 750;
$pageTopYLandscape = 570; 36 36 $pageTopYLandscape = 570;
37 37
38 38
// wrap PDFlib usage in a try{} block 39 39 // wrap PDFlib usage in a try{} block
try { 40 40 try {
$pdf = new PDFlib(); 41 41 $pdf = new PDFlib();
42 42
// set up some PDFlib options 43 43 // set up some PDFlib options
$pdf->set_option("errorpolicy=return"); 44 44 $pdf->set_option("errorpolicy=return");
$pdf->set_option("stringformat=utf8"); 45 45 $pdf->set_option("stringformat=utf8");
46 46
if ($pdf->begin_document($outfile, "") == 0) 47 47 if ($pdf->begin_document($outfile, "") == 0)
throw new Exception("Error: " . $pdf->get_errmsg()); 48 48 throw new Exception("Error: " . $pdf->get_errmsg());
49 49
// set up the document metadata info 50 50 // set up the document metadata info
$pdf->set_info('Creator', 'IODP Science Support Office'); 51 51 $pdf->set_info('Creator', 'IODP Science Support Office');
$pdf->set_info('Author', 'IODP Science Support Office'); 52 52 $pdf->set_info('Author', 'IODP Science Support Office');
$pdf->set_info('Title', 'Demo of TCPDF for generating IODP Proposals'); 53 53 $pdf->set_info('Title', 'Demo of TCPDF for generating IODP Proposals');
$pdf->set_info('Subject', 'IODP Proposals'); 54 54 $pdf->set_info('Subject', 'IODP Proposals');
$pdf->set_info('Keywords', 'IODP proposal ocean drilling core expedition'); 55 55 $pdf->set_info('Keywords', 'IODP proposal ocean drilling core expedition');
56 56
$textOpts = "fontname={Helvetica} embedding fontsize=20 " 57 57 $textOpts = "fontname={Helvetica} embedding fontsize=20 "
. "encoding=unicode "; 58 58 . "encoding=unicode ";
59 59
// START PAGE 1 60 60 // START PAGE 1
$pdf->begin_page_ext(612, 792, ''); 61 61 $pdf->begin_page_ext(612, 792, '');
62 62
// create bookmarks first thing 63 63 // create bookmarks first thing
$action = $pdf->create_action("GoTo", "destination={page=1}"); 64 64 $action = $pdf->create_action("GoTo", "destination={page=1}");
$pdf->create_bookmark("Page 1", " action={activate= " . $action . "}"); 65 65 $pdf->create_bookmark("Page 1", " action={activate= " . $action . "}");
66 66
// action 67 67 // action
$action = $pdf->create_action("GoTo", "destination={page=2}"); 68 68 $action = $pdf->create_action("GoTo", "destination={page=2}");
// bookmark 69 69 // bookmark
$pdf->create_bookmark("Page 2", " action={activate= " . $action . "}"); 70 70 $pdf->create_bookmark("Page 2", " action={activate= " . $action . "}");
71 71
72 72
// text/image 73 73 // text/image
$pdf->fit_textline("Jump to SSF for SHACK-10A", 20, 750, 74 74 $pdf->fit_textline("Jump to SSF for SHACK-10A", 20, 750,
$textOpts . " underline=true matchbox={name=to_second_page}"); 75 75 $textOpts . " underline=true matchbox={name=to_second_page}");
// annotation; reuse the "page 2" action above 76 76 // annotation; reuse the "page 2" action above
$optlist = "action={activate " . $action . "} linewidth=0 " . 77 77 $optlist = "action={activate " . $action . "} linewidth=0 " .
"usematchbox={to_second_page}"; 78 78 "usematchbox={to_second_page}";
$pdf->create_annotation(0, 0, 0, 0, "Link", $optlist); 79 79 $pdf->create_annotation(0, 0, 0, 0, "Link", $optlist);
80 80
// the rest of the text on page 1 81 81 // the rest of the text on page 1
$pdf->fit_textline("This is some text on the first page; ", 20, 720, 82 82 $pdf->fit_textline("This is some text on the first page; ", 20, 720,
$textOpts); 83 83 $textOpts);
$pdf->fit_textline("Привет! Этот немного текста.", 20, 690, $textOpts); 84 84 $pdf->fit_textline("Привет! Этот немного текста.", 20, 690, $textOpts);
85 85
// END PAGE 1 86 86 // END PAGE 1
$pdf->end_page_ext(''); 87 87 $pdf->end_page_ext('');
88 88
// START PAGE 2 89 89 // START PAGE 2
//$pdf->begin_page_ext(612, 792, ''); 90 90 //$pdf->begin_page_ext(612, 792, '');
$ssfPDF = $pdf->open_pdi_document(__DIR__ . "/site_summary_figure.pdf", ''); 91 91 $ssfPDF = $pdf->open_pdi_document(__DIR__ . "/site_summary_figure.pdf", '');
if ($ssfPDF == 0) 92 92 if ($ssfPDF == 0)
throw new Exception("Error: " . $p->get_errmsg()); 93 93 throw new Exception("Error: " . $p->get_errmsg());
94 94
$ssfPage = $pdf->open_pdi_page($ssfPDF, 1, ''); 95 95 $ssfPage = $pdf->open_pdi_page($ssfPDF, 1, '');
$ssfWidth = $pdf->pcos_get_number($ssfPDF, "pages[0]/width"); 96 96 $ssfWidth = $pdf->pcos_get_number($ssfPDF, "pages[0]/width");
$ssfHeight = $pdf->pcos_get_number($ssfPDF, "pages[0]/height"); 97 97 $ssfHeight = $pdf->pcos_get_number($ssfPDF, "pages[0]/height");
//print "Page width/height: $ssfWidth x $ssfHeight\n"; 98 98 //print "Page width/height: $ssfWidth x $ssfHeight\n";
99 99
$pdf->begin_page_ext($ssfWidth, $ssfHeight, ''); 100 100 $pdf->begin_page_ext($ssfWidth, $ssfHeight, '');
101 101
$pdf->fit_pdi_page($ssfPage, 0, 0, ''); 102 102 $pdf->fit_pdi_page($ssfPage, 0, 0, '');
$pdf->close_pdi_page($ssfPage); 103 103 $pdf->close_pdi_page($ssfPage);
$pdf->close_pdi_document($ssfPDF); 104 104 $pdf->close_pdi_document($ssfPDF);
105 105
// write some text on to the page 106 106 // write some text on to the page