Commit f4c7b335c296e2f676d56396c480b670baa6747f
0 parents
Exists in
master
Added files for PDFlib demo script
Showing 2 changed files with 89 additions and 0 deletions Side-by-side Diff
pdflib_demo
View file @
f4c7b33
... | ... | @@ -0,0 +1,89 @@ |
1 | +#!/usr/bin/env php | |
2 | + | |
3 | +<?php | |
4 | +/** | |
5 | + * FILENAME: | |
6 | + * tfpdf_demo | |
7 | + * | |
8 | + * DESCRIPTION: | |
9 | + * Demonstration of the tFPDF PHP Library for generating PDF files | |
10 | + * | |
11 | + */ | |
12 | + | |
13 | +/** | |
14 | + Links: | |
15 | + - https://packagist.org/packages/rev42/tfpdf | |
16 | + - https://packagist.org/packages/setasign/fpdi | |
17 | + - http://www.fpdf.org/ | |
18 | + - http://www.fpdf.org/en/doc/index.php | |
19 | + - http://www.fpdf.org/en/tutorial/index.php | |
20 | + - http://www.fpdf.org/en/tutorial/tuto6.htm (Links and flowing text) | |
21 | + - http://www.tcpdf.org/doc/code/classTCPDF-members.html | |
22 | + | |
23 | + This script also requires FPDI to load PDF documents into memory | |
24 | + - https://www.setasign.com/products/fpdi/about/ | |
25 | + - https://www.setasign.com/products/fpdi/manual/#p-200 | |
26 | + | |
27 | + NOTE the line 'use tFPDF as FPDF;' needs to be added to the FPDI | |
28 | + library, specifically in vendor/setasign/fpdi/fpdi_bridge.php, line 19, | |
29 | + for FPDI to work | |
30 | +*/ | |
31 | + | |
32 | +$loader = require __DIR__ . '/vendor/autoload.php'; | |
33 | +$loader->register(); | |
34 | + | |
35 | +// set a default timezone | |
36 | +date_default_timezone_set("America/Los_Angeles"); | |
37 | + | |
38 | +//require_once('tcpdf_include.php'); | |
39 | +//$pdf = new TCPDF('p', 'mm', 'Letter', TRUE, 'UTF-8'); | |
40 | +class_exists('TCPDF', true); | |
41 | +$pdf = new FPDI('p', 'mm', 'Letter', TRUE, 'UTF-8'); | |
42 | +// disable headers and footers on all pages | |
43 | +$pdf->setPrintHeader(FALSE); | |
44 | +$pdf->setPrintFooter(FALSE); | |
45 | + | |
46 | +// write out the contents of the first page | |
47 | +$pdf->AddPage(); | |
48 | +$topLink = $pdf->AddLink(); | |
49 | +$pdf->SetLink($topLink); | |
50 | +//$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true); | |
51 | +$pdf->AddFont('dejavusanscondensed','','dejavusanscondensed.php',true); | |
52 | +//$pdf->SetFont('DejaVu', '', 20); | |
53 | +$pdf->SetFont('dejavusanscondensed', '', 20); | |
54 | +$pdf->SetFont('', 'U'); | |
55 | +$ssfLink = $pdf->AddLink(); | |
56 | +$pdf->Write(10, "Jump to SSF for SHACK-10A", $ssfLink); | |
57 | +$pdf->SetFont(''); | |
58 | +$pdf->Ln(); | |
59 | +$pdf->Write(10, "This is some text on the first page; "); | |
60 | +$pdf->Ln(); | |
61 | +$pdf->Write(10, "Привет! Этот немного текста."); | |
62 | + | |
63 | +// load up the Site Summary Figure to go on page #2 | |
64 | +$ssfPageCount = $pdf->setSourceFile(__DIR__ . '/site_summary_figure.pdf'); | |
65 | +//print "Page count of site summary figure form is $ssfPageCount\n"; | |
66 | + | |
67 | +// import the SSF page | |
68 | +$ssfTemplate= $pdf->importPage(1); | |
69 | +//print "Page size of site summary figure PDF is: "; | |
70 | +//$ssfSize = $pdf->getTemplateSize($ssfTemplate); | |
71 | +//print "{$ssfSize['w']}mm x {$ssfSize['h']}mm\n"; | |
72 | + | |
73 | +// add the SSF file to the 2nd page | |
74 | +$pdf->AddPage(); | |
75 | +$pdf->SetLink($ssfLink); | |
76 | +$pdf->useTemplate($ssfTemplate); | |
77 | +$pdf->SetFont('Helvetica'); | |
78 | +$pdf->SetXY(5,5); | |
79 | +$pdf->SetFont('', 'U'); | |
80 | +$pdf->Write(8, "Top", $topLink); | |
81 | +$pdf->SetFont(''); | |
82 | +$pdf->SetXY(40, 5); | |
83 | +$pdf->Write(8, " SSF: P771/SHACK-10A"); | |
84 | + | |
85 | +// destination, F = "local file"; filename; isUTF8 (boolean) | |
86 | +//$pdf->Output('F', 'output.pdf', TRUE); | |
87 | +$pdf->Output(__DIR__ . '/output.pdf', 'F'); | |
88 | + | |
89 | +// vim: expandtab filetype=php shiftwidth=3 tabstop=3 |
site_summary_figure.pdf
View file @
f4c7b33