Commit b27ca2a95df4172bfb478e6a5f74f3ad4edef01c

Authored by Brian Manning
0 parents
Exists in master

Initial commit with files copied from tFPDF

Showing 4 changed files with 96 additions and 0 deletions Side-by-side Diff

... ... @@ -0,0 +1,10 @@
  1 +# VIM swap files
  2 +*.swp
  3 +# Mac metadata files
  4 +.DS_Store
  5 +# vendor/ directory from Composer
  6 +vendor/
  7 +# don't complain about the machine-specific test_constants.php file
  8 +bin/constants.php
  9 +# ignore the output file
  10 +output.pdf
composer.json View file @ b27ca2a
... ... @@ -0,0 +1,8 @@
  1 +{
  2 + "name": "GDC/tfpdf_demo",
  3 + "description": "Demo of the tFPDF library",
  4 + "require": {
  5 + "rev42/tfpdf": "v1.25",
  6 + "setasign/fpdi": "1.6.1"
  7 + }
  8 +}
site_summary_figure.pdf View file @ b27ca2a

No preview for this file type

... ... @@ -0,0 +1,78 @@
  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 +
  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 tFPDF 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->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);
  41 +$pdf->SetFont('DejaVu', '', 20);
  42 +$pdf->SetFont('', 'U');
  43 +$ssfLink = $pdf->AddLink();
  44 +$pdf->Write(10, "Jump SSF for SHACK-10A", $ssfLink);
  45 +$pdf->SetFont('');
  46 +$pdf->Ln();
  47 +$pdf->Write(10, "This is some text on the first page; ");
  48 +$pdf->Ln();
  49 +$pdf->Write(10, "Привет! Этот немного текста.");
  50 +
  51 +// load up the Site Summary Figure to go on page #2
  52 +$ssfPageCount = $pdf->setSourceFile(__DIR__ . '/site_summary_figure.pdf');
  53 +
  54 +print "Page count of site summary figure form is $ssfPageCount\n";
  55 +
  56 +// import the SSF page
  57 +$ssfTemplate= $pdf->importPage(1);
  58 +print "Page size of site summary figure PDF is: ";
  59 +$ssfSize = $pdf->getTemplateSize($ssfTemplate);
  60 +print "{$ssfSize['w']} x {$ssfSize['h']}\n";
  61 +
  62 +// add the SSF file to the 2nd page
  63 +$pdf->AddPage();
  64 +$pdf->SetLink($ssfLink);
  65 +$pdf->useTemplate($ssfTemplate);
  66 +$pdf->SetFont('Helvetica');
  67 +$pdf->SetXY(5,5);
  68 +$pdf->SetFont('', 'U');
  69 +$pdf->Write(8, "Top", $topLink);
  70 +$pdf->SetFont('');
  71 +$pdf->SetXY(40, 5);
  72 +$pdf->Write(8, " SSF: P771/SHACK-10A");
  73 +
  74 +// destination, F = "local file"; filename; isUTF8 (boolean)
  75 +//$pdf->Output('F', 'output.pdf', TRUE);
  76 +$pdf->Output('output.pdf', 'F');
  77 +
  78 +// vim: expandtab filetype=php shiftwidth=3 tabstop=3