|
2 | 2 | include_once 'Sample_Header.php';
|
3 | 3 |
|
4 | 4 | // New Word Document
|
5 |
| -echo date('H:i:s') , " Create new PhpWord object" , EOL; |
| 5 | +echo date('H:i:s') , ' Create new PhpWord object' , EOL; |
6 | 6 | $phpWord = new \PhpOffice\PhpWord\PhpWord();
|
7 | 7 | $phpWord->addFontStyle('rStyle', array('bold' => true, 'italic' => true, 'size' => 16, 'allCaps' => true, 'doubleStrikethrough' => true));
|
8 | 8 | $phpWord->addParagraphStyle('pStyle', array('align' => 'center', 'spaceAfter' => 100));
|
|
12 | 12 | $section = $phpWord->addSection();
|
13 | 13 |
|
14 | 14 | // Simple text
|
15 |
| -$section->addTitle('Welcome to PhpWord', 1); |
16 |
| -$section->addText('Hello World!'); |
| 15 | +$section->addTitle(htmlspecialchars('Welcome to PhpWord'), 1); |
| 16 | +$section->addText(htmlspecialchars('Hello World!')); |
17 | 17 |
|
18 | 18 | // Two text break
|
19 | 19 | $section->addTextBreak(2);
|
20 | 20 |
|
21 | 21 | // Defined style
|
22 |
| -$section->addText('I am styled by a font style definition.', 'rStyle'); |
23 |
| -$section->addText('I am styled by a paragraph style definition.', null, 'pStyle'); |
24 |
| -$section->addText('I am styled by both font and paragraph style.', 'rStyle', 'pStyle'); |
| 22 | +$section->addText(htmlspecialchars('I am styled by a font style definition.'), 'rStyle'); |
| 23 | +$section->addText(htmlspecialchars('I am styled by a paragraph style definition.'), null, 'pStyle'); |
| 24 | +$section->addText(htmlspecialchars('I am styled by both font and paragraph style.'), 'rStyle', 'pStyle'); |
25 | 25 |
|
26 | 26 | $section->addTextBreak();
|
27 | 27 |
|
|
30 | 30 | $fontStyle['size'] = 20;
|
31 | 31 |
|
32 | 32 | $textrun = $section->addTextRun();
|
33 |
| -$textrun->addText('I am inline styled ', $fontStyle); |
34 |
| -$textrun->addText('with '); |
35 |
| -$textrun->addText('color', array('color' => '996699')); |
36 |
| -$textrun->addText(', '); |
37 |
| -$textrun->addText('bold', array('bold' => true)); |
38 |
| -$textrun->addText(', '); |
39 |
| -$textrun->addText('italic', array('italic' => true)); |
40 |
| -$textrun->addText(', '); |
41 |
| -$textrun->addText('underline', array('underline' => 'dash')); |
42 |
| -$textrun->addText(', '); |
43 |
| -$textrun->addText('strikethrough', array('strikethrough' => true)); |
44 |
| -$textrun->addText(', '); |
45 |
| -$textrun->addText('doubleStrikethrough', array('doubleStrikethrough' => true)); |
46 |
| -$textrun->addText(', '); |
47 |
| -$textrun->addText('superScript', array('superScript' => true)); |
48 |
| -$textrun->addText(', '); |
49 |
| -$textrun->addText('subScript', array('subScript' => true)); |
50 |
| -$textrun->addText(', '); |
51 |
| -$textrun->addText('smallCaps', array('smallCaps' => true)); |
52 |
| -$textrun->addText(', '); |
53 |
| -$textrun->addText('allCaps', array('allCaps' => true)); |
54 |
| -$textrun->addText(', '); |
55 |
| -$textrun->addText('fgColor', array('fgColor' => 'yellow')); |
56 |
| -$textrun->addText(', '); |
57 |
| -$textrun->addText('scale', array('scale' => 200)); |
58 |
| -$textrun->addText(', '); |
59 |
| -$textrun->addText('spacing', array('spacing' => 120)); |
60 |
| -$textrun->addText(', '); |
61 |
| -$textrun->addText('kerning', array('kerning' => 10)); |
62 |
| -$textrun->addText('. '); |
| 33 | +$textrun->addText(htmlspecialchars('I am inline styled '), $fontStyle); |
| 34 | +$textrun->addText(htmlspecialchars('with ')); |
| 35 | +$textrun->addText(htmlspecialchars('color'), array('color' => '996699')); |
| 36 | +$textrun->addText(htmlspecialchars(', ')); |
| 37 | +$textrun->addText(htmlspecialchars('bold'), array('bold' => true)); |
| 38 | +$textrun->addText(htmlspecialchars(', ')); |
| 39 | +$textrun->addText(htmlspecialchars('italic'), array('italic' => true)); |
| 40 | +$textrun->addText(htmlspecialchars(', ')); |
| 41 | +$textrun->addText(htmlspecialchars('underline'), array('underline' => 'dash')); |
| 42 | +$textrun->addText(htmlspecialchars(', ')); |
| 43 | +$textrun->addText(htmlspecialchars('strikethrough'), array('strikethrough' => true)); |
| 44 | +$textrun->addText(htmlspecialchars(', ')); |
| 45 | +$textrun->addText(htmlspecialchars('doubleStrikethrough'), array('doubleStrikethrough' => true)); |
| 46 | +$textrun->addText(htmlspecialchars(', ')); |
| 47 | +$textrun->addText(htmlspecialchars('superScript'), array('superScript' => true)); |
| 48 | +$textrun->addText(htmlspecialchars(', ')); |
| 49 | +$textrun->addText(htmlspecialchars('subScript'), array('subScript' => true)); |
| 50 | +$textrun->addText(htmlspecialchars(', ')); |
| 51 | +$textrun->addText(htmlspecialchars('smallCaps'), array('smallCaps' => true)); |
| 52 | +$textrun->addText(htmlspecialchars(', ')); |
| 53 | +$textrun->addText(htmlspecialchars('allCaps'), array('allCaps' => true)); |
| 54 | +$textrun->addText(htmlspecialchars(', ')); |
| 55 | +$textrun->addText(htmlspecialchars('fgColor'), array('fgColor' => 'yellow')); |
| 56 | +$textrun->addText(htmlspecialchars(', ')); |
| 57 | +$textrun->addText(htmlspecialchars('scale'), array('scale' => 200)); |
| 58 | +$textrun->addText(htmlspecialchars(', ')); |
| 59 | +$textrun->addText(htmlspecialchars('spacing'), array('spacing' => 120)); |
| 60 | +$textrun->addText(htmlspecialchars(', ')); |
| 61 | +$textrun->addText(htmlspecialchars('kerning'), array('kerning' => 10)); |
| 62 | +$textrun->addText(htmlspecialchars('. ')); |
63 | 63 |
|
64 | 64 | // Link
|
65 |
| -$section->addLink('http://www.google.com', 'Google'); |
| 65 | +$section->addLink('http://www.google.com', htmlspecialchars('Google')); |
66 | 66 | $section->addTextBreak();
|
67 | 67 |
|
68 | 68 | // Image
|
|
0 commit comments