Commit 28c9cdc976dd4b8e79849f46eb5224aef9494bd2
1 parent
342e12266b
Exists in
master
tfpdf_demo: updated links to docs/examples
Showing 1 changed file with 9 additions and 0 deletions Inline Diff
tfpdf_demo
View file @
28c9cdc
#!/usr/bin/env php | 1 | 1 | #!/usr/bin/env php | |
2 | 2 | |||
<?php | 3 | 3 | <?php | |
/** | 4 | 4 | /** | |
* FILENAME: | 5 | 5 | * FILENAME: | |
* tfpdf_demo | 6 | 6 | * tfpdf_demo | |
* | 7 | 7 | * | |
* DESCRIPTION: | 8 | 8 | * DESCRIPTION: | |
* Demonstration of the tFPDF PHP Library for generating PDF files | 9 | 9 | * Demonstration of the tFPDF PHP Library for generating PDF files | |
* | 10 | 10 | * | |
*/ | 11 | 11 | */ | |
12 | 12 | |||
/** | 13 | 13 | /** | |
Links: | 14 | 14 | Links: | |
- https://packagist.org/packages/rev42/tfpdf | 15 | 15 | - https://packagist.org/packages/rev42/tfpdf | |
- https://packagist.org/packages/setasign/fpdi | 16 | 16 | - https://packagist.org/packages/setasign/fpdi | |
- http://www.fpdf.org/ | 17 | 17 | - http://www.fpdf.org/ | |
- http://www.fpdf.org/en/doc/index.php | 18 | 18 | - http://www.fpdf.org/en/doc/index.php | |
- http://www.fpdf.org/en/tutorial/index.php | 19 | 19 | - http://www.fpdf.org/en/tutorial/index.php | |
20 | - http://www.fpdf.org/en/tutorial/tuto5.htm (Tables) | |||
- http://www.fpdf.org/en/tutorial/tuto6.htm (Links and flowing text) | 20 | 21 | - http://www.fpdf.org/en/tutorial/tuto6.htm (Links and flowing text) | |
22 | - http://www.fpdf.org/en/script/script92.php (Documentation of UTF-8 script) | |||
21 | 23 | |||
This script also requires FPDI to load PDF documents into memory | 22 | 24 | This script also requires FPDI to load PDF documents into memory | |
- https://www.setasign.com/products/fpdi/about/ | 23 | 25 | - https://www.setasign.com/products/fpdi/about/ | |
- https://www.setasign.com/products/fpdi/manual/#p-200 | 24 | 26 | - https://www.setasign.com/products/fpdi/manual/#p-200 | |
25 | 27 | |||
NOTE the line 'use tFPDF as FPDF;' needs to be added to the FPDI | 26 | 28 | NOTE the line 'use tFPDF as FPDF;' needs to be added to the FPDI | |
library, specifically in vendor/setasign/fpdi/fpdi_bridge.php, line 19, | 27 | 29 | library, specifically in vendor/setasign/fpdi/fpdi_bridge.php, line 19, | |
for FPDI to work | 28 | 30 | for FPDI to work | |
31 | ||||
32 | Extra scripts that might come in handy: | |||
33 | - Bookmarks - http://www.fpdf.org/en/script/script1.php | |||
34 | - Table with MultiCells - http://www.fpdf.org/en/script/script3.php | |||
35 | - Rounded Rectangles - http://www.fpdf.org/en/script/script35.php | |||
36 | - Table of Contents - http://www.fpdf.org/en/script/script73.php | |||
37 | ||||
*/ | 29 | 38 | */ | |
30 | 39 | |||
$loader = require __DIR__ . '/vendor/autoload.php'; | 31 | 40 | $loader = require __DIR__ . '/vendor/autoload.php'; | |
$loader->register(); | 32 | 41 | $loader->register(); | |
33 | 42 | |||
$pdf = new FPDI('p', 'mm', 'Letter'); | 34 | 43 | $pdf = new FPDI('p', 'mm', 'Letter'); | |
35 | 44 | |||
// write out the contents of the first page | 36 | 45 | // write out the contents of the first page | |
$pdf->AddPage(); | 37 | 46 | $pdf->AddPage(); | |
$topLink = $pdf->AddLink(); | 38 | 47 | $topLink = $pdf->AddLink(); | |
$pdf->SetLink($topLink); | 39 | 48 | $pdf->SetLink($topLink); | |
$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true); | 40 | 49 | $pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true); | |
$pdf->SetFont('DejaVu', '', 20); | 41 | 50 | $pdf->SetFont('DejaVu', '', 20); | |
$pdf->SetFont('', 'U'); | 42 | 51 | $pdf->SetFont('', 'U'); | |
$ssfLink = $pdf->AddLink(); | 43 | 52 | $ssfLink = $pdf->AddLink(); | |
$pdf->Write(10, "Jump to SSF for SHACK-10A", $ssfLink); | 44 | 53 | $pdf->Write(10, "Jump to SSF for SHACK-10A", $ssfLink); | |
$pdf->SetFont(''); | 45 | 54 | $pdf->SetFont(''); | |
$pdf->Ln(); | 46 | 55 | $pdf->Ln(); | |
$pdf->Write(10, "This is some text on the first page; "); | 47 | 56 | $pdf->Write(10, "This is some text on the first page; "); | |
$pdf->Ln(); | 48 | 57 | $pdf->Ln(); | |
$pdf->Write(10, "Привет! Этот немного текста."); | 49 | 58 | $pdf->Write(10, "Привет! Этот немного текста."); | |
50 | 59 | |||
// load up the Site Summary Figure to go on page #2 | 51 | 60 | // load up the Site Summary Figure to go on page #2 | |
$ssfPageCount = $pdf->setSourceFile(__DIR__ . '/site_summary_figure.pdf'); | 52 | 61 | $ssfPageCount = $pdf->setSourceFile(__DIR__ . '/site_summary_figure.pdf'); | |
53 | 62 | |||
//print "Page count of site summary figure form is $ssfPageCount\n"; | 54 | 63 | //print "Page count of site summary figure form is $ssfPageCount\n"; | |
55 | 64 | |||
// import the SSF page | 56 | 65 | // import the SSF page | |
$ssfTemplate= $pdf->importPage(1); | 57 | 66 | $ssfTemplate= $pdf->importPage(1); | |
// NOTE the page sizes are in millimeters, as that's what we specified when | 58 | 67 | // NOTE the page sizes are in millimeters, as that's what we specified when | |
// the PDF document was first created (above) | 59 | 68 | // the PDF document was first created (above) | |
//print "Page size of site summary figure PDF is: "; | 60 | 69 | //print "Page size of site summary figure PDF is: "; | |
//$ssfSize = $pdf->getTemplateSize($ssfTemplate); | 61 | 70 | //$ssfSize = $pdf->getTemplateSize($ssfTemplate); | |
//print "{$ssfSize['w']}mm x {$ssfSize['h']}mm\n"; | 62 | 71 | //print "{$ssfSize['w']}mm x {$ssfSize['h']}mm\n"; | |
63 | 72 | |||
// add the SSF file to the 2nd page | 64 | 73 | // add the SSF file to the 2nd page | |
$pdf->AddPage(); | 65 | 74 | $pdf->AddPage(); | |
$pdf->SetLink($ssfLink); | 66 | 75 | $pdf->SetLink($ssfLink); | |
$pdf->useTemplate($ssfTemplate); | 67 | 76 | $pdf->useTemplate($ssfTemplate); |