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