Commit c3e38f79064db447bc94a893ad2b63d9a7caf3ef

Authored by Brian Manning
1 parent 840f46a604
Exists in master

tcpdf_demo: disable headers/footers; added link to TCPDF Packagist page

Showing 1 changed file with 4 additions and 0 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:
* 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
- http://www.fpdf.org/en/tutorial/tuto6.htm (Links and flowing text) 20 20 - http://www.fpdf.org/en/tutorial/tuto6.htm (Links and flowing text)
21 - http://www.tcpdf.org/doc/code/classTCPDF-members.html
21 22
This script also requires FPDI to load PDF documents into memory 22 23 This script also requires FPDI to load PDF documents into memory
- https://www.setasign.com/products/fpdi/about/ 23 24 - https://www.setasign.com/products/fpdi/about/
- https://www.setasign.com/products/fpdi/manual/#p-200 24 25 - https://www.setasign.com/products/fpdi/manual/#p-200
25 26
NOTE the line 'use tFPDF as FPDF;' needs to be added to the FPDI 26 27 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 28 library, specifically in vendor/setasign/fpdi/fpdi_bridge.php, line 19,
for FPDI to work 28 29 for FPDI to work
*/ 29 30 */
30 31
$loader = require __DIR__ . '/vendor/autoload.php'; 31 32 $loader = require __DIR__ . '/vendor/autoload.php';
$loader->register(); 32 33 $loader->register();
33 34
// set a default timezone 34 35 // set a default timezone
date_default_timezone_set("America/Los_Angeles"); 35 36 date_default_timezone_set("America/Los_Angeles");
36 37
//require_once('tcpdf_include.php'); 37 38 //require_once('tcpdf_include.php');
//$pdf = new TCPDF('p', 'mm', 'Letter', TRUE, 'UTF-8'); 38 39 //$pdf = new TCPDF('p', 'mm', 'Letter', TRUE, 'UTF-8');
class_exists('TCPDF', true); 39 40 class_exists('TCPDF', true);
$pdf = new FPDI('p', 'mm', 'Letter', TRUE, 'UTF-8'); 40 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);
41 45
// write out the contents of the first page 42 46 // write out the contents of the first page
$pdf->AddPage(); 43 47 $pdf->AddPage();
$topLink = $pdf->AddLink(); 44 48 $topLink = $pdf->AddLink();
$pdf->SetLink($topLink); 45 49 $pdf->SetLink($topLink);
//$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true); 46 50 //$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);
$pdf->AddFont('dejavusanscondensed','','dejavusanscondensed.php',true); 47 51 $pdf->AddFont('dejavusanscondensed','','dejavusanscondensed.php',true);
//$pdf->SetFont('DejaVu', '', 20); 48 52 //$pdf->SetFont('DejaVu', '', 20);
$pdf->SetFont('dejavusanscondensed', '', 20); 49 53 $pdf->SetFont('dejavusanscondensed', '', 20);
$pdf->SetFont('', 'U'); 50 54 $pdf->SetFont('', 'U');
$ssfLink = $pdf->AddLink(); 51 55 $ssfLink = $pdf->AddLink();
$pdf->Write(10, "Jump to SSF for SHACK-10A", $ssfLink); 52 56 $pdf->Write(10, "Jump to SSF for SHACK-10A", $ssfLink);
$pdf->SetFont(''); 53 57 $pdf->SetFont('');
$pdf->Ln(); 54 58 $pdf->Ln();
$pdf->Write(10, "This is some text on the first page; "); 55 59 $pdf->Write(10, "This is some text on the first page; ");
$pdf->Ln(); 56 60 $pdf->Ln();
$pdf->Write(10, "Привет! Этот немного текста."); 57 61 $pdf->Write(10, "Привет! Этот немного текста.");
58 62
// load up the Site Summary Figure to go on page #2 59 63 // load up the Site Summary Figure to go on page #2
$ssfPageCount = $pdf->setSourceFile(__DIR__ . '/site_summary_figure.pdf'); 60 64 $ssfPageCount = $pdf->setSourceFile(__DIR__ . '/site_summary_figure.pdf');
//print "Page count of site summary figure form is $ssfPageCount\n"; 61 65 //print "Page count of site summary figure form is $ssfPageCount\n";
62 66
// import the SSF page 63 67 // import the SSF page
$ssfTemplate= $pdf->importPage(1); 64 68 $ssfTemplate= $pdf->importPage(1);
//print "Page size of site summary figure PDF is: "; 65 69 //print "Page size of site summary figure PDF is: ";
//$ssfSize = $pdf->getTemplateSize($ssfTemplate); 66 70 //$ssfSize = $pdf->getTemplateSize($ssfTemplate);
//print "{$ssfSize['w']}mm x {$ssfSize['h']}mm\n"; 67 71 //print "{$ssfSize['w']}mm x {$ssfSize['h']}mm\n";
68 72
// add the SSF file to the 2nd page 69 73 // add the SSF file to the 2nd page
$pdf->AddPage(); 70 74 $pdf->AddPage();
$pdf->SetLink($ssfLink); 71 75 $pdf->SetLink($ssfLink);
$pdf->useTemplate($ssfTemplate); 72 76 $pdf->useTemplate($ssfTemplate);