wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
PDFTemplate Class Reference

Public Member Functions

 PDFTemplate (&$pdf)
 
 setTemplate ($filename)
 
 setPages ($pages, $cycle=false, $data=null)
 
 output ($name='', $dest='')
 

Public Attributes

 $_pdf = null
 
 $_tpl = null
 
 $_pages = array()
 
 $_cycle = false
 
 $_data = null
 

Detailed Description

PDFTemplate is used to output pdf files based on a given pdf template. PDFTemplate uses FPDI/FPDF. PDFPage instances are used to render data onto the template pages.

wCMF - wemove Content Management Framework Copyright (C) 2005-2014 wemove digital solutions GmbH

Licensed under the terms of any of the following licenses at your choice:

See the license.txt file distributed with this work for additional information.

Id:
class.PDFTemplate.php 1462 2014-02-04 23:52:27Z iherwig

The following example shows the usage:

// example Controller method to show a pdf download dialog
// Page1 extends PDFPage and defines what is rendered onto the template
function executeKernel()
{
$template = new PDFTemplate(new MyPDF());
// set the template
$template->setTemplate('include/pdf/wcmf.pdf');
// render Page1 on every second template page
$template->setPages(array(new Page1(), null), true);
// output the final page
$downloadfile = 'wcmf.pdf';
header("Content-disposition: attachment; filename=$downloadfile");
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: binary");
header("Pragma: no-cache");
header("Expires: 0");
echo $template->output($downloadfile, 'S');
}
Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 55 of file class.PDFTemplate.php.

Member Function Documentation

PDFTemplate::PDFTemplate ( $pdf)

Constructor

Parameters
pdfThe PDF instance to render onto, defaults to PDF created with default constructor

Definition at line 67 of file class.PDFTemplate.php.

PDFTemplate::setTemplate (   $filename)

Set the template filename

Parameters
filenameThe name of the file

Definition at line 79 of file class.PDFTemplate.php.

PDFTemplate::setPages (   $pages,
  $cycle = false,
  $data = null 
)

Set the PDFPage instances used to write the content to the template. The page instances will be used one after another: The 1 instance writes to the first template page, the second to the second and so on. Use the cycle parameter to cycle the instances (e.g. if the same data should be written to every template page, put one instance into the pages array and set cycle to true)

Parameters
pagesAn array of PDFPage instances
cycleTrue/False wether to cycle the PDFPage instances or not [default: false]
dataAn optional data object, that will passed to the PDFPage::render method [default: null]

Definition at line 94 of file class.PDFTemplate.php.

PDFTemplate::output (   $name = '',
  $dest = '' 
)

Output the pdf. Delegates to FPDF::Output()

See Also
http://www.fpdf.de/funktionsreferenz/Output/
Parameters
nameThe name of the pdf file
destThe pdf destination ('I': browser inline, 'D': browser download, 'F': filesystem, 'S': string)
Returns
The document string in case of dest = 'S', nothing else

Definition at line 108 of file class.PDFTemplate.php.

References WCMFException\throwEx().

+ Here is the call graph for this function:

Member Data Documentation

PDFTemplate::$_pdf = null

Definition at line 57 of file class.PDFTemplate.php.

PDFTemplate::$_tpl = null

Definition at line 58 of file class.PDFTemplate.php.

PDFTemplate::$_pages = array()

Definition at line 59 of file class.PDFTemplate.php.

PDFTemplate::$_cycle = false

Definition at line 60 of file class.PDFTemplate.php.

PDFTemplate::$_data = null

Definition at line 61 of file class.PDFTemplate.php.


The documentation for this class was generated from the following file: