2014-03-03 20:15:29 +01:00
|
|
|
<?php
|
2014-03-15 22:39:57 +07:00
|
|
|
include_once 'Sample_Header.php';
|
2014-03-03 20:15:29 +01:00
|
|
|
|
|
|
|
|
// New Word Document
|
2015-01-01 20:41:42 +04:00
|
|
|
echo date('H:i:s'), ' Create new PhpWord object', EOL;
|
2014-03-23 10:32:08 +04:00
|
|
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
2014-03-03 20:15:29 +01:00
|
|
|
|
|
|
|
|
// New portrait section
|
2014-04-02 11:02:56 +07:00
|
|
|
$section = $phpWord->addSection(array('borderColor' => '00FF00', 'borderSize' => 12));
|
2015-02-06 22:28:31 +04:00
|
|
|
$section->addText(htmlspecialchars('I am placed on a default section.', ENT_COMPAT, 'UTF-8'));
|
2014-03-03 20:15:29 +01:00
|
|
|
|
|
|
|
|
// New landscape section
|
2014-04-02 11:02:56 +07:00
|
|
|
$section = $phpWord->addSection(array('orientation' => 'landscape'));
|
2015-01-01 20:41:42 +04:00
|
|
|
$section->addText(
|
|
|
|
|
htmlspecialchars(
|
2015-02-06 22:28:31 +04:00
|
|
|
'I am placed on a landscape section. Every page starting from this section will be landscape style.',
|
|
|
|
|
ENT_COMPAT,
|
|
|
|
|
'UTF-8'
|
2015-01-01 20:41:42 +04:00
|
|
|
)
|
|
|
|
|
);
|
2014-03-03 20:15:29 +01:00
|
|
|
$section->addPageBreak();
|
|
|
|
|
$section->addPageBreak();
|
|
|
|
|
|
|
|
|
|
// New portrait section
|
2015-01-01 20:41:42 +04:00
|
|
|
$section = $phpWord->addSection(
|
|
|
|
|
array('paperSize' => 'Folio', 'marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600)
|
|
|
|
|
);
|
2015-02-06 22:28:31 +04:00
|
|
|
$section->addText(htmlspecialchars('This section uses other margins with folio papersize.', ENT_COMPAT, 'UTF-8'));
|
2014-03-03 20:15:29 +01:00
|
|
|
|
|
|
|
|
// New portrait section with Header & Footer
|
2015-01-01 20:41:42 +04:00
|
|
|
$section = $phpWord->addSection(
|
|
|
|
|
array(
|
|
|
|
|
'marginLeft' => 200,
|
|
|
|
|
'marginRight' => 200,
|
|
|
|
|
'marginTop' => 200,
|
|
|
|
|
'marginBottom' => 200,
|
|
|
|
|
'headerHeight' => 50,
|
|
|
|
|
'footerHeight' => 50,
|
|
|
|
|
)
|
|
|
|
|
);
|
2015-02-06 22:28:31 +04:00
|
|
|
$section->addText(htmlspecialchars('This section and we play with header/footer height.', ENT_COMPAT, 'UTF-8'));
|
|
|
|
|
$section->addHeader()->addText(htmlspecialchars('Header', ENT_COMPAT, 'UTF-8'));
|
|
|
|
|
$section->addFooter()->addText(htmlspecialchars('Footer', ENT_COMPAT, 'UTF-8'));
|
2014-03-03 20:15:29 +01:00
|
|
|
|
2014-03-12 21:55:20 +07: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';
|
2014-03-12 21:55:20 +07:00
|
|
|
}
|