Compare View

switch
from
...
to
 
Commits (2)

Diff

Showing 3 changed files Inline Diff

fonts/FreeSans.ttf View file @ b3cc9ca

No preview for this file type

fonts/FreeSerif.ttf View file @ b3cc9ca

No preview for this file type

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