@@ -24,13 +24,9 @@ folder <https://github.com/PHPOffice/PHPWord/tree/master/samples/>`__.
24
24
$section = $phpWord->addSection();
25
25
// Adding Text element to the Section having font styled by default...
26
26
$section->addText(
27
- htmlspecialchars(
28
- '"Learn from yesterday, live for today, hope for tomorrow. '
29
- . 'The important thing is not to stop questioning." '
30
- . '(Albert Einstein)',
31
- ENT_COMPAT,
32
- 'UTF-8'
33
- )
27
+ '"Learn from yesterday, live for today, hope for tomorrow. '
28
+ . 'The important thing is not to stop questioning." '
29
+ . '(Albert Einstein)'
34
30
);
35
31
36
32
/*
@@ -42,13 +38,9 @@ folder <https://github.com/PHPOffice/PHPWord/tree/master/samples/>`__.
42
38
43
39
// Adding Text element with font customized inline...
44
40
$section->addText(
45
- htmlspecialchars(
46
- '"Great achievement is usually born of great sacrifice, '
47
- . 'and is never the result of selfishness." '
48
- . '(Napoleon Hill)',
49
- ENT_COMPAT,
50
- 'UTF-8'
51
- ),
41
+ '"Great achievement is usually born of great sacrifice, '
42
+ . 'and is never the result of selfishness." '
43
+ . '(Napoleon Hill)',
52
44
array('name' => 'Tahoma', 'size' => 10)
53
45
);
54
46
@@ -59,13 +51,9 @@ folder <https://github.com/PHPOffice/PHPWord/tree/master/samples/>`__.
59
51
array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)
60
52
);
61
53
$section->addText(
62
- htmlspecialchars(
63
- '"The greatest accomplishment is not in never falling, '
64
- . 'but in rising again after you fall." '
65
- . '(Vince Lombardi)',
66
- ENT_COMPAT,
67
- 'UTF-8'
68
- ),
54
+ '"The greatest accomplishment is not in never falling, '
55
+ . 'but in rising again after you fall." '
56
+ . '(Vince Lombardi)',
69
57
$fontStyleName
70
58
);
71
59
@@ -74,9 +62,7 @@ folder <https://github.com/PHPOffice/PHPWord/tree/master/samples/>`__.
74
62
$fontStyle->setBold(true);
75
63
$fontStyle->setName('Tahoma');
76
64
$fontStyle->setSize(13);
77
- $myTextElement = $section->addText(
78
- htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)', ENT_COMPAT, 'UTF-8')
79
- );
65
+ $myTextElement = $section->addText('"Believe you can and you\'re halfway there." (Theodor Roosevelt)');
80
66
$myTextElement->setFontStyle($fontStyle);
81
67
82
68
// Saving the document as OOXML file...
@@ -130,8 +116,22 @@ included with PHPWord.
130
116
131
117
\PhpOffice\PhpWord\Settings::setZipClass(\PhpOffice\PhpWord\Settings::PCLZIP);
132
118
119
+ Output escaping
120
+ ~~~~~~~~~~~~~~~
121
+
122
+ Writing documents of some formats, especially XML-based, requires correct output escaping.
123
+ Without it your document may become broken when you put special characters like ampersand, quotes, and others in it.
124
+
125
+ Escaping can be performed in two ways: outside of the library by a software developer and inside of the library by built-in mechanism.
126
+ By default, the built-in mechanism is disabled for backward compatibility with versions prior to v0.13.0.
127
+ To turn it on set ``outputEscapingEnabled `` option to ``true `` in your PHPWord configuration file or use the following instruction at runtime:
128
+
129
+ .. code-block :: php
130
+
131
+ \PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(true);
132
+
133
133
Default font
134
- ------------
134
+ ~~~~~~~~~~~~
135
135
136
136
By default, every text appears in Arial 10 point. You can alter the
137
137
default font by using the following two functions:
0 commit comments