PHPWord/samples/Sample_02_TabStops.php

41 lines
1.2 KiB
PHP
Raw Normal View History

2013-12-15 14:35:18 +01:00
<?php
2014-03-15 22:39:57 +07:00
include_once 'Sample_Header.php';
2013-12-15 14:35:18 +01:00
// New Word Document
2015-01-01 20:41:42 +04:00
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
2013-12-15 14:35:18 +01:00
// Ads styles
2015-01-01 20:41:42 +04:00
$phpWord->addParagraphStyle(
'multipleTab',
array(
'tabs' => array(
new \PhpOffice\PhpWord\Style\Tab('left', 1550),
new \PhpOffice\PhpWord\Style\Tab('center', 3200),
new \PhpOffice\PhpWord\Style\Tab('right', 5300),
)
)
);
$phpWord->addParagraphStyle(
'rightTab',
array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('right', 9090)))
);
$phpWord->addParagraphStyle(
'centerTab',
array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('center', 4680)))
);
2013-12-15 14:35:18 +01:00
// New portrait section
$section = $phpWord->addSection();
2013-12-15 14:35:18 +01:00
// Add listitem elements
$section->addText(htmlspecialchars("Multiple Tabs:\tOne\tTwo\tThree", ENT_COMPAT, 'UTF-8'), null, 'multipleTab');
$section->addText(htmlspecialchars("Left Aligned\tRight Aligned", ENT_COMPAT, 'UTF-8'), null, 'rightTab');
$section->addText(htmlspecialchars("\tCenter Aligned", ENT_COMPAT, 'UTF-8'), null, 'centerTab');
2013-12-15 14:35:18 +01:00
// Save file
2014-04-12 10:12:24 +07:00
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}