Multi
class Multi extends AbstractWriter
Methods
Add Multi-line content to the PDF
Add Multi-line content to the PDF
Add Multi-line content to the PDF
Sets the new mult-line configuration
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 ] );
at line 165
addMultiCenter(string $html, array $position = [], string $overflow = 'auto', array $config = [])
Add Multi-line content to the PDF
at line 187
addMultiRight(string $html, array $position = [], string $overflow = 'auto', array $config = [])
Add Multi-line content to the PDF
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 ] );
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'];