PHPWord/samples/Sample_19_TextBreak.php

33 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2014-03-15 22:39:57 +07:00
include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), " Create new PhpWord object", EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// Begin code
$fontStyle = array('size' => 24);
$paragraphStyle = array('spacing' => 240, 'size' => 24);
$phpWord->addFontStyle('fontStyle', array('size' => 9));
$phpWord->addParagraphStyle('paragraphStyle', array('spacing' => 480));
$fontStyle = array('size' => 24);
$section = $phpWord->addSection();
$section->addText('Text break with no style:');
$section->addTextBreak();
$section->addText('Text break with defined font style:');
$section->addTextBreak(1, 'fontStyle');
$section->addText('Text break with defined paragraph style:');
$section->addTextBreak(1, null, 'paragraphStyle');
$section->addText('Text break with inline font style:');
$section->addTextBreak(1, $fontStyle);
$section->addText('Text break with inline paragraph style:');
$section->addTextBreak(1, null, $paragraphStyle);
$section->addText('Done.');
// Save file
2014-04-12 10:12:24 +07:00
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}