class Multi extends AbstractWriter

Methods

void
addMulti(string $html, array $position = [], string $overflow = 'auto', array $config = [])

Add Multi-line content to the PDF

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

Add Multi-line content to the PDF

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

Add Multi-line content to the PDF

void
configMulti(array $config)

Sets the new mult-line configuration

array
getMultiConfig()

Return the current Multi configuration values

Details

at line 110
void addMulti(string $html, array $position = [], string $overflow = 'auto', array $config = [])

Add Multi-line content to the PDF

Add content to the PDF which has a fixed positioned and is better configured for multiline output (better line height defaults at the expense of less accurate Y positioning).

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

The default configuration is as follows, but can be overriden for each call:

  • font-size: UI Font Size|10pt - Controls the font size used
  • line-height: (UI Font Size * 1.4)|14pt - Controls the line height used
  • strip-br: false - Whether to strip BR tags and replace them with 3 hard spaces.

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 .multi for more convenient styling. The X/Y positioning is from the top-left of the element being included.

The font-size and line-height are always calculated in points and the units should NOT be included when changing the configuration defaults.

Example

 // Add multi-line 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->addMulti( 'Line 1<br>Line2<br>Line3', [ 20, 50, 30, 5 ] );

 // Instead of shrinking the content to fit the container, the 'visible' property will allow it to overflow the container
 $w->addMulti( 'Line 1<br>Line2<br>Line3', [ 20, 50, 30, 5 ], 'visible' );

 // Will override the default configuration and auto-strip BR tags and increase the font size on a one-time basis
 $w->addMulti( 'Line 1<br>Line2<br>Line3', [ 20, 50, 30, 5 ], 'auto', [ 'font-size' => 14, 'line-height' => 20, 'strip-br' => true ] );

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 arguments include "auto" or "visible"
array $config Override the default configuration on a per-element basis. Accepted array keys include 'font-size', 'line-height', 'strip-br'

Return Value

void

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 165
addMultiCenter(string $html, array $position = [], string $overflow = 'auto', array $config = [])

Add Multi-line content to the PDF

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 arguments include "auto" or "visible"
array $config Override the default configuration on a per-element basis. Accepted array keys include 'font-size', 'line-height', 'strip-br'

See also

Multi::addMulti for full documentation ## Example // Add multi-line 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->addMultiCenter( 'Line 1
Line2
Line3', [ 20, 50, 30, 5 ] );

at line 187
addMultiRight(string $html, array $position = [], string $overflow = 'auto', array $config = [])

Add Multi-line content to the PDF

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 arguments include "auto" or "visible"
array $config Override the default configuration on a per-element basis. Accepted array keys include 'font-size', 'line-height', 'strip-br'

See also

Multi::addMulti 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->addMultiRight( 'Line 1
Line2
Line3', [ 20, 50, 30, 5 ] );

at line 229
void configMulti(array $config)

Sets the new mult-line configuration

Once called, all future calls to $w->addMulti() will use these defaults

The default configuration is:

  • font-size: 10pt - Controls the font size used
  • line-height: 14pt - Controls the line height used
  • strip-br: false - Whether to strip BR tags and replace them with 3 hard spaces.

The font-size and line-height are always calculated in points and the units should NOT be included when changing the configuration defaults.

Example

 // Adds multi-line text with the default
 $w->addMulti( 'Line 1<br>Line2<br>Line3', [ 20, 50, 30, 5 ] );

 // Changes the default config font size and line height
 $w->configMulti( [
     'font-size' => 14,
     'line-height' => 20,
 ] );

 // Adds multi-line text with the new defaults
 $w->addMulti( 'Line 1<br>Line2<br>Line3', [ 20, 50, 30, 5 ] );

 // Will override the defaults just for this content
 $w->addMulti( 'Line 1<br>Line2<br>Line3', [ 20, 50, 30, 5 ], 'auto', [ 'font-size' => 8, 'line-height' => 12 ] );

Parameters

array $config Accepted array keys include 'font-size', 'line-height', 'strip-br'

Return Value

void

at line 263
array getMultiConfig()

Return the current Multi configuration values

Example

 // Get the current Multi config
 $config = $w->getMultiConfig();

 echo $config['font-size'];
 echo $config['line-height'];
 echo $config['strip-br'];

Return Value

array Returned array keys include 'font-size', 'line-height', 'strip-br'