forked from PHPOffice/PHPWord
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Sample_19_TextBreak.php
32 lines (28 loc) · 1.32 KB
/
Sample_19_TextBreak.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
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(htmlspecialchars('Text break with no style:', ENT_COMPAT, 'UTF-8'));
$section->addTextBreak();
$section->addText(htmlspecialchars('Text break with defined font style:', ENT_COMPAT, 'UTF-8'));
$section->addTextBreak(1, 'fontStyle');
$section->addText(htmlspecialchars('Text break with defined paragraph style:', ENT_COMPAT, 'UTF-8'));
$section->addTextBreak(1, null, 'paragraphStyle');
$section->addText(htmlspecialchars('Text break with inline font style:', ENT_COMPAT, 'UTF-8'));
$section->addTextBreak(1, $fontStyle);
$section->addText(htmlspecialchars('Text break with inline paragraph style:', ENT_COMPAT, 'UTF-8'));
$section->addTextBreak(1, null, $paragraphStyle);
$section->addText(htmlspecialchars('Done.', ENT_COMPAT, 'UTF-8'));
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}