Page New in 0.2.0 Version 0.4.0
Describes single page
Properties
Name | Type | Access | Description |
---|---|---|---|
$blocks New in 0.4.0 | BlockCollection | Read Only | Stores page content as list of block elements |
$info | PageInfo | Read Only | Stores page meta informations |
$items Deprecated in 0.4.0 | Text[] | Read Only | Stores page content |
Methods
Name | Type | Description |
---|---|---|
addPagebreak() New in 0.4.0 | PageBreak | Append new PageBreak block |
addParagraph() New in 0.4.0 | Paragraph | Append new Paragraph block |
addText() Deprecated in 0.5.0 | TextBlock | Append new text entry wrapped into TextBlock. Legacy method, use Paragraph instead. |
Examples
Simple page with multiple paragraphs
$page->addParagraph()->addRun("First line text");
$page->addParagraph()->addRun("Second line text");
$page->addParagraph()->addRun("Multi line text\nMany lines as one\nSeparated with new line character");
Page with defined size and orientation
$page = new Page([
'orientation' => PageOrientationInfo::getPortrait(),
'size' => PageSizeInfo::getA5()
]);
Simple page with styled paragraphs and text
$page->addParagraph()->addRun("First line text");
$page->addParagraph()->addRun("Second line text", [
'fontFamily' => 'Courier',
'fontSize' => 10
]);
$page->addParagraph([
'textIndent' => 1.10
])->addRun("Multi line text\nMany lines as one\nSeparated with new line character", [
'fontSize' => 11
]);
Simple page with multiline text
// Legacy example, starting 0.4.0 the paragraph is recommended
$page->addText("First line text");
$page->addText("Second line text");
$page->addText("Multi line text\nMany lines as one\nSeparated with new line character");