Compare View
Commits (2)
Diff
Showing 2 changed files Side-by-side Diff
.gitignore
View file @
5b78410
pdflib_demo
View file @
5b78410
... | ... | @@ -15,23 +15,63 @@ |
15 | 15 | - https://www.pdflib.com/developer/technical-documentation/manuals/ |
16 | 16 | - https://www.pdflib.com/pdflib-cookbook/browse-all-topics/ |
17 | 17 | |
18 | - PDFlib was loaded via a Homebrew package for working with this demo | |
19 | 18 | */ |
20 | 19 | |
21 | -$loader = require __DIR__ . '/vendor/autoload.php'; | |
22 | -$loader->register(); | |
23 | - | |
24 | 20 | // set a default timezone |
25 | 21 | date_default_timezone_set("America/Los_Angeles"); |
26 | 22 | |
27 | 23 | //require_once('tcpdf_include.php'); |
28 | -//$pdf = new TCPDF('p', 'mm', 'Letter', TRUE, 'UTF-8'); | |
29 | -class_exists('TCPDF', true); | |
30 | -$pdf = new FPDI('p', 'mm', 'Letter', TRUE, 'UTF-8'); | |
31 | -// disable headers and footers on all pages | |
32 | -$pdf->setPrintHeader(FALSE); | |
33 | -$pdf->setPrintFooter(FALSE); | |
24 | +$outfile = __DIR__ . '/output.pdf'; | |
25 | + | |
26 | +// wrap PDFlib usage in a try{} block | |
27 | +try { | |
28 | + $pdf = new PDFlib(); | |
29 | + | |
30 | + // set up some PDFlib options | |
31 | + $pdf->set_option("errorpolicy=return"); | |
32 | + $pdf->set_option("stringformat=utf8"); | |
33 | + | |
34 | + if ($pdf->begin_document($outfile, "") == 0) | |
35 | + throw new Exception("Error: " . $pdf->get_errmsg()); | |
36 | + | |
37 | + // set up the document metadata info | |
38 | + $pdf->set_info('Creator', 'IODP Science Support Office'); | |
39 | + $pdf->set_info('Author', 'IODP Science Support Office'); | |
40 | + $pdf->set_info('Title', 'Demo of TCPDF for generating IODP Proposals'); | |
41 | + $pdf->set_info('Subject', 'IODP Proposals'); | |
42 | + $pdf->set_info('Keywords', 'IODP proposal ocean drilling core expedition'); | |
43 | + | |
44 | + $pdf->begin_page_ext(612, 792, ''); | |
45 | + | |
46 | + $textOpts = "fontname={Helvetica} embedding fontsize=20 " | |
47 | + . "encoding=unicode "; | |
48 | + | |
49 | + $pdf->fit_textline("Jump to SSF for SHACK-10A", 20, 750, $textOpts); | |
50 | + $pdf->fit_textline("This is some text on the first page; ", 20, 720, | |
51 | + $textOpts); | |
52 | + $pdf->fit_textline("Привет! Этот немного текста.", 20, 690, $textOpts); | |
34 | 53 | |
54 | + // finish this page | |
55 | + $pdf->end_page_ext(''); | |
56 | + | |
57 | + // close the document | |
58 | + $pdf->end_document(''); | |
59 | + | |
60 | +} | |
61 | + | |
62 | +catch (PDFlibException $e) { | |
63 | + die("PDFlib exception occurred in sample:\n" . | |
64 | + "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " . | |
65 | + $e->get_errmsg() . "\n"); | |
66 | +} | |
67 | + | |
68 | +catch (Exception $e) { | |
69 | + die($e); | |
70 | +} | |
71 | + | |
72 | +$p = 0; | |
73 | + | |
74 | +/* | |
35 | 75 | // write out the contents of the first page |
36 | 76 | $pdf->AddPage(); |
37 | 77 | $topLink = $pdf->AddLink(); |
... | ... | @@ -74,5 +114,6 @@ $pdf->Write(8, " SSF: P771/SHACK-10A"); |
74 | 114 | // destination, F = "local file"; filename; isUTF8 (boolean) |
75 | 115 | //$pdf->Output('F', 'output.pdf', TRUE); |
76 | 116 | $pdf->Output(__DIR__ . '/output.pdf', 'F'); |
117 | +*/ | |
77 | 118 | |
78 | 119 | // vim: expandtab filetype=php shiftwidth=3 tabstop=3 |