class Single extends AbstractWriter

Methods

add(string $html, array $position = [], string $overflow = 'auto')

Add Single Line content to PDF

addCenter(string $html, array $position = [], string $overflow = 'auto')

Add Single Line content to PDF with center alignment

addRight(string $html, array $position = [], string $overflow = 'auto')

Add Single Line content to PDF with right alignment

Details

at line 75
add(string $html, array $position = [], string $overflow = 'auto')

Add Single Line content to PDF

Add content to the PDF that has a fixed positioned and is better suited for a single line of text (the line height matches the font size for more accurate positioning). This is the main way you overlay content onto your PDF documents.

The $position is always calculated in millimeters and the units should NOT be included.

By default, if the text extends outside the container it will be shrunk to fit (this can be overriden).

All content added with this method will be wrapped in a DIV with the class .single for more convenient styling.

Example

 // Add content to the current page positioned 20mm from the left, 50mm from the top, with a width of 30mm and a height of 5mm
 $w->add( 'My content', [ 20, 50, 30, 5 ] );

 // Instead of shrinking the content to fit the container, the 'visible' property will allow it to overflow the container
 $w->add( 'My content', [ 20, 50, 30, 5 ], 'visible' );

Parameters

string $html The content to add to the PDF being rendered
array $position The X, Y, Width and Height of the element
string $overflow Whether to show or resize the $html if the content doesn't fit inside the width/height. Accepted parameters include "auto" or "visible"

Exceptions

BadMethodCallException Will be thrown if $position doesn't include four array items (x, y, width, height), if $overflow doesn't include an accepted argument, or $html is not a string

at line 113
addCenter(string $html, array $position = [], string $overflow = 'auto')

Add Single Line content to PDF with center alignment

Parameters

string $html The content to add to the PDF being rendered
array $position The X, Y, Width and Height of the element
string $overflow Whether to show or resize the $html if the content doesn't fit inside the width/height. Accepted parameters include "auto" or "visible"

See also

Single::add for full documentation ## Example // Add content to the current page positioned 20mm from the left, 50mm from the top, with a width of 30mm, a height of 5mm and aligned right $w->addCenter( 'My content', [ 20, 50, 30, 5 ] );

at line 134
addRight(string $html, array $position = [], string $overflow = 'auto')

Add Single Line content to PDF with right alignment

Parameters

string $html The content to add to the PDF being rendered
array $position The X, Y, Width and Height of the element
string $overflow Whether to show or resize the $html if the content doesn't fit inside the width/height. Accepted parameters include "auto" or "visible"

See also

Single::add for full documentation ## Example // Add content to the current page positioned 20mm from the left, 50mm from the top, with a width of 30mm, a height of 5mm and aligned right $w->addRight( 'My content', [ 20, 50, 30, 5 ] );