FpdfTplTrait
Trait FpdfTplTrait
This trait adds a templating feature to FPDF and tFPDF.
Table of Contents
Properties
- $currentTemplateId : null|int
- The template id for the currently created template.
- $templateId : int
- A counter for template ids.
- $templates : array<string|int, mixed>
- Data of all created templates.
Methods
- _out() : mixed
- AddPage() : mixed
- beginTemplate() : int
- Begins a new template.
- endTemplate() : bool|int|null
- Ends a template.
- getTemplateSize() : array<string|int, mixed>|bool
- Get the size of a template.
- Link() : mixed
- SetDrawColor() : mixed
- SetFillColor() : mixed
- SetFont() : mixed
- SetFontSize() : mixed
- SetLineWidth() : mixed
- SetLink() : mixed
- setPageFormat() : mixed
- Set the page format of the current page.
- useTemplate() : array<string|int, mixed>
- Draws a template onto the page or another template.
- _putimages() : mixed
- _putxobjectdict() : mixed
- getNextTemplateId() : int
- Get the next template id.
Properties
$currentTemplateId
The template id for the currently created template.
protected
null|int
$currentTemplateId
$templateId
A counter for template ids.
protected
int
$templateId
= 0
$templates
Data of all created templates.
protected
array<string|int, mixed>
$templates
= []
Methods
_out()
public
_out(mixed $s) : mixed
Parameters
- $s : mixed
Tags
AddPage()
public
AddPage([mixed $orientation = '' ][, mixed $size = '' ][, mixed $rotation = 0 ]) : mixed
Parameters
- $orientation : mixed = ''
- $size : mixed = ''
- $rotation : mixed = 0
Tags
beginTemplate()
Begins a new template.
public
beginTemplate([float|int|null $width = null ][, float|int|null $height = null ][, bool $groupXObject = false ]) : int
Parameters
- $width : float|int|null = null
-
The width of the template. If null, the current page width is used.
- $height : float|int|null = null
-
The height of the template. If null, the current page height is used.
- $groupXObject : bool = false
-
Define the form XObject as a group XObject to support transparency (if used).
Return values
int —A template identifier.
endTemplate()
Ends a template.
public
endTemplate() : bool|int|null
Return values
bool|int|null —A template identifier.
getTemplateSize()
Get the size of a template.
public
getTemplateSize(mixed $tpl[, float|int|null $width = null ][, float|int|null $height = null ]) : array<string|int, mixed>|bool
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 = null
-
The width.
- $height : float|int|null = null
-
The height.
Return values
array<string|int, mixed>|bool —An array with following keys: width, height, 0 (=width), 1 (=height), orientation (L or P)
Link()
public
Link(mixed $x, mixed $y, mixed $w, mixed $h, mixed $link) : mixed
Parameters
- $x : mixed
- $y : mixed
- $w : mixed
- $h : mixed
- $link : mixed
Tags
SetDrawColor()
public
SetDrawColor(mixed $r[, mixed $g = null ][, mixed $b = null ]) : mixed
Parameters
- $r : mixed
- $g : mixed = null
- $b : mixed = null
Tags
SetFillColor()
public
SetFillColor(mixed $r[, mixed $g = null ][, mixed $b = null ]) : mixed
Parameters
- $r : mixed
- $g : mixed = null
- $b : mixed = null
Tags
SetFont()
public
SetFont(mixed $family[, mixed $style = '' ][, mixed $size = 0 ]) : mixed
Parameters
- $family : mixed
- $style : mixed = ''
- $size : mixed = 0
Tags
SetFontSize()
public
SetFontSize(mixed $size) : mixed
Parameters
- $size : mixed
Tags
SetLineWidth()
public
SetLineWidth(mixed $width) : mixed
Parameters
- $width : mixed
Tags
SetLink()
public
SetLink(mixed $link[, mixed $y = 0 ][, mixed $page = -1 ]) : mixed
Parameters
- $link : mixed
- $y : mixed = 0
- $page : mixed = -1
Tags
setPageFormat()
Set the page format of the current page.
public
setPageFormat(array<string|int, mixed> $size, string $orientation) : mixed
Parameters
- $size : array<string|int, mixed>
-
An array with two values defining the size.
- $orientation : string
-
"L" for landscape, "P" for portrait.
Tags
useTemplate()
Draws a template onto the page or another template.
public
useTemplate(mixed $tpl[, array<string|int, mixed>|float|int $x = 0 ][, float|int $y = 0 ][, float|int|null $width = null ][, float|int|null $height = null ][, bool $adjustPageSize = false ]) : array<string|int, mixed>
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<string|int, mixed>|float|int = 0
-
The abscissa of upper-left corner. Alternatively you could use an assoc array with the keys "x", "y", "width", "height", "adjustPageSize".
- $y : float|int = 0
-
The ordinate of upper-left corner.
- $width : float|int|null = null
-
The width.
- $height : float|int|null = null
-
The height.
- $adjustPageSize : bool = false
Tags
Return values
array<string|int, mixed> —The size
_putimages()
protected
_putimages() : mixed
_putxobjectdict()
protected
_putxobjectdict() : mixed
Tags
getNextTemplateId()
Get the next template id.
protected
getNextTemplateId() : int