FPDF_TPL Class FPDF_TPL

File: /FPDI v1/fpdf_tpl.php

Class hierarchy

Summary

Properties

$_inTpl

protected boolean FPDF_TPL::$_inTpl = false

"In Template"-Flag

$_res

protected array FPDF_TPL::$_res = array()

Resources used by templates and pages

$_tpls

protected array FPDF_TPL::$_tpls = array()

Array of template data

$lastUsedTemplateData

public array FPDF_TPL::$lastUsedTemplateData = array()

Last used template data

$tpl

public int FPDF_TPL::$tpl = 0

Current Template-Id

$tplPrefix

public string FPDF_TPL::$tplPrefix = '/TPL'

Name prefix of templates used in Resources dictionary

A String defining the Prefix used as Template-Object-Names. Have to begin with an /


Methods

AddLink()

public FPDF_TPL::AddLink (
void
): void

Creates a new internal link and returns its identifier.

Overwritten because adding links in a template will not work.

See

AddPage()

public FPDF_TPL::AddPage (
[ $orientation = '' [, $format = '' [, $rotationOrKeepmargins = false [, $tocpage = false ]]]]
): void

Adds a new page to the document.

See FPDF/TCPDF documentation.

This method cannot be used if you'd started a template.

Parameters
$orientation
 
$format
 
$rotationOrKeepmargins
 
$tocpage
 
See

Image()

public FPDF_TPL::Image (
$file [, $x = '' [, $y = '' [, $w = 0 [, $h = 0 [, $type = '' [, $link = '' [, $align = '' [, $resize = false [, $dpi = 300 [, $palign = '' [, $ismask = false [, $imgmask = false [, $border = 0 [, $fitbox = false [, $hidden = false [, $fitonpage = false [, $alt = false [, $altimgs = array ( ) ]]]]]]]]]]]]]]]]]]
): void

Puts an image.

See FPDF/TCPDF documentation.

Parameters
$file
 
$x
 
$y
 
$w
 
$h
 
$type
 
$link
 
$align
 
$resize
 
$dpi
 
$palign
 
$ismask
 
$imgmask
 
$border
 
$fitbox
 
$hidden
 
$fitonpage
 
$alt
 
$altimgs
 
See

Link()

public FPDF_TPL::Link (
$x, $y, $w, $h, $link [, $spaces = 0 ]
): void

Puts a link on a rectangular area of the page.

Overwritten because adding links in a template will not work.

Parameters
$x
 
$y
 
$w
 
$h
 
$link
 
$spaces
 
See

SetFont()

public FPDF_TPL::SetFont (
$family [, $style = '' [, $size = null [, $fontfile = '' [, $subset = 'default' [, $out = true ]]]]]
): void

Sets the font used to print character strings.

See FPDF/TCPDF documentation.

Parameters
$family
 
$style
 
$size
 
$fontfile
 
$subset
 
$out
 
See

SetLink()

public FPDF_TPL::SetLink (
$link [, $y = 0 [, $page = -1 ]]
): void

Defines the page and position a link points to.

Overwritten because adding links in a template will not work.

Parameters
$link
 
$y
 
$page
 
See

_out()

public FPDF_TPL::_out (
string $s
): void

Writes bytes to the resulting document.

Overwritten to delegate the data to the template buffer.

Parameters
$s : string
 

_putformxobjects()

protected FPDF_TPL::_putformxobjects (
void
): void

Writes the form XObjects to the PDF document.

_putimages()

public FPDF_TPL::_putimages (
void
): void

Output images.

Overwritten to add _putformxobjects() after _putimages().

_putxobjectdict()

public FPDF_TPL::_putxobjectdict (
void
): void

Writes the references of XObject resources to the document.

Overwritten to add the the templates to the XObject resource dictionary.

beginTemplate()

public FPDF_TPL::beginTemplate (
[ int $x = null [, int $y = null [, int $w = null [, int $h = null ]]]]
): int

Start a template.

This method starts a template. You can give own coordinates to build an own sized template. Pay attention, that the margins are adapted to the new template size. If you want to write outside the template, for example to build a clipped template, you have to set the margins and "cursor"-position manual after beginTemplate()-call.

If no parameter is given, the template uses the current page-size. The method returns an id of the current template. This id is used later for using this template. Warning: A created template is saved in the resulting PDF at all events. Also if you don't use it after creation!

Parameters
$x : int

The x-coordinate given in user-unit

$y : int

The y-coordinate given in user-unit

$w : int

The width given in user-unit

$h : int

The height given in user-unit

Return Values

The id of new created template

Exceptions

Throws LogicException

endTemplate()

public FPDF_TPL::endTemplate (
void
): int|boolean

End template.

This method ends a template and reset initiated variables collected in beginTemplate().

Return Values

If a template is opened, the id is returned. If not a false is returned.

getTemplateSize()

public FPDF_TPL::getTemplateSize (
int $tplIdx [, int $w = 0 [, int $h = 0 ]]
): array

Get the calculated size of a template.

If one size is given, this method calculates the other one.

Parameters
$tplIdx : int

A valid template-id

$w : int

The width of the template

$h : int

The height of the template

Return Values

The height and width of the template (array('w' => ..., 'h' => ...))

useTemplate()

public FPDF_TPL::useTemplate (
int $tplIdx [, int $x = null [, int $y = null [, int $w = 0 [, int $h = 0 ]]]]
): array

Use a template in current page or other template.

You can use a template in a page or in another template. You can give the used template a new size. All parameters are optional. The width or height is calculated automatically if one is given. If no parameter is given the origin size as defined in beginTemplate() method is used.

The calculated or used width and height are returned as an array.

Parameters
$tplIdx : int

A valid template-id

$x : int

The x-position

$y : int

The y-position

$w : int

The new width of the template

$h : int

The new height of the template

Return Values

The height and width of the template (array('w' => ..., 'h' => ...))

Exceptions

Throws LogicException,InvalidArgumentException