Commit 3c4200bfa9e85766835331064ae72205cd9f4cd6

Authored by Brian Manning
1 parent 74b317f858
Exists in master

fpdf_demo: adjusted some comments at the top of the script

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