setasign\Fpdi

FpdfTplTrait Trait FpdfTplTrait

File: /FPDI v2/FpdfTplTrait.php

This trait adds a templating feature to FPDF and tFPDF.

Used in

Summary

Properties

$currentTemplateId

The template id for the currently created template.

$templateId

protected int FpdfTplTrait::$templateId = 0

A counter for template ids.

$templates

protected array FpdfTplTrait::$templates = array()

Data of all created templates.


Methods

AddPage()

public FpdfTplTrait::AddPage (
$orientation = '',
$size = '',
$rotation = 0
): void
Parameters
$orientation
 
$size
 
$rotation
 

Link()

public FpdfTplTrait::Link (
$x,
$y,
$w,
$h,
$link
): void
Parameters
$x
 
$y
 
$w
 
$h
 
$link
 

SetDrawColor()

public FpdfTplTrait::SetDrawColor (
$r,
$g = null,
$b = null
): void
Parameters
$r
 
$g
 
$b
 

SetFillColor()

public FpdfTplTrait::SetFillColor (
$r,
$g = null,
$b = null
): void
Parameters
$r
 
$g
 
$b
 

SetFont()

public FpdfTplTrait::SetFont (
$family,
$style = '',
$size = 0
): void
Parameters
$family
 
$style
 
$size
 

SetFontSize()

public FpdfTplTrait::SetFontSize (
$size
): void
Parameters
$size
 

SetLineWidth()

public FpdfTplTrait::SetLineWidth (
$width
): void
Parameters
$width
 

SetLink()

public FpdfTplTrait::SetLink (
$link,
$y = 0,
$page = -1
): void
Parameters
$link
 
$y
 
$page
 

_out()

public FpdfTplTrait::_out (
$s
): void
Parameters
$s
 

_putimages()

protected FpdfTplTrait::_putimages (
void
): void

_putxobjectdict()

protected FpdfTplTrait::_putxobjectdict (
void
): void

beginTemplate()

public FpdfTplTrait::beginTemplate (
float|int|null $width = null,
float|int|null $height = null,
bool $groupXObject = false
): int

Begins a new template.

Parameters
$width : float|int|null

The width of the template. If null, the current page width is used.

$height : float|int|null

The height of the template. If null, the current page height is used.

$groupXObject : bool

Define the form XObject as a group XObject to support transparency (if used).

Return Values

A template identifier.

endTemplate()

public FpdfTplTrait::endTemplate (
void
): bool|int|null

Ends a template.

Return Values

A template identifier.

getNextTemplateId()

protected FpdfTplTrait::getNextTemplateId (
void
): int

Get the next template id.

getTemplateSize()

public FpdfTplTrait::getTemplateSize (
mixed $tpl,
float|int|null $width = null,
float|int|null $height = null
): array|bool

Get the size of a template.

Give only one of the size parameters (width, height) to calculate the other one automatically in view to the aspect ratio.

Parameters
$tpl : mixed

The template id

$width : float|int|null

The width.

$height : float|int|null

The height.

Return Values

An array with following keys: width, height, 0 (=width), 1 (=height), orientation (L or P)

setPageFormat()

public FpdfTplTrait::setPageFormat (
array $size,
string $orientation
): void

Set the page format of the current page.

Parameters
$size : array

An array with two values defining the size.

$orientation : string

"L" for landscape, "P" for portrait.

Exceptions

Throws \BadMethodCallException

useTemplate()

public FpdfTplTrait::useTemplate (
mixed $tpl,
array|float|int $x = 0,
float|int $y = 0,
float|int|null $width = null,
float|int|null $height = null,
bool $adjustPageSize = false
): array

Draws a template onto the page or another template.

Give only one of the size parameters (width, height) to calculate the other one automatically in view to the aspect ratio.

Parameters
$tpl : mixed

The template id

$x : array|float|int

The abscissa of upper-left corner. Alternatively you could use an assoc array with the keys "x", "y", "width", "height", "adjustPageSize".

$y : float|int

The ordinate of upper-left corner.

$width : float|int|null

The width.

$height : float|int|null

The height.

$adjustPageSize : bool
 
Return Values

The size

See