2014-03-14 22:03:19 +07:00
|
|
|
<?php
|
2014-03-15 22:39:57 +07:00
|
|
|
include_once 'Sample_Header.php';
|
2014-03-14 22:03:19 +07: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-14 22:03:19 +07:00
|
|
|
|
|
|
|
|
// Begin code
|
|
|
|
|
$fontStyle = array('size' => 24);
|
|
|
|
|
$paragraphStyle = array('spacing' => 240, 'size' => 24);
|
2014-03-20 16:54:12 +04:00
|
|
|
$phpWord->addFontStyle('fontStyle', array('size' => 9));
|
|
|
|
|
$phpWord->addParagraphStyle('paragraphStyle', array('spacing' => 480));
|
2014-03-14 22:03:19 +07:00
|
|
|
$fontStyle = array('size' => 24);
|
|
|
|
|
|
2014-04-02 11:02:56 +07:00
|
|
|
$section = $phpWord->addSection();
|
2015-02-06 22:28:31 +04:00
|
|
|
$section->addText(htmlspecialchars('Text break with no style:', ENT_COMPAT, 'UTF-8'));
|
2014-03-14 22:03:19 +07:00
|
|
|
$section->addTextBreak();
|
2015-02-06 22:28:31 +04:00
|
|
|
$section->addText(htmlspecialchars('Text break with defined font style:', ENT_COMPAT, 'UTF-8'));
|
2014-03-14 22:03:19 +07:00
|
|
|
$section->addTextBreak(1, 'fontStyle');
|
2015-02-06 22:28:31 +04:00
|
|
|
$section->addText(htmlspecialchars('Text break with defined paragraph style:', ENT_COMPAT, 'UTF-8'));
|
2014-03-14 22:03:19 +07:00
|
|
|
$section->addTextBreak(1, null, 'paragraphStyle');
|
2015-02-06 22:28:31 +04:00
|
|
|
$section->addText(htmlspecialchars('Text break with inline font style:', ENT_COMPAT, 'UTF-8'));
|
2014-03-14 22:03:19 +07:00
|
|
|
$section->addTextBreak(1, $fontStyle);
|
2015-02-06 22:28:31 +04:00
|
|
|
$section->addText(htmlspecialchars('Text break with inline paragraph style:', ENT_COMPAT, 'UTF-8'));
|
2014-03-14 22:03:19 +07:00
|
|
|
$section->addTextBreak(1, null, $paragraphStyle);
|
2015-02-06 22:28:31 +04:00
|
|
|
$section->addText(htmlspecialchars('Done.', ENT_COMPAT, 'UTF-8'));
|
2014-03-14 22:03:19 +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-14 22:03:19 +07:00
|
|
|
}
|