@@ -98,27 +98,42 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
98
98
$section = $phpWord->addSection();
99
99
// Adding Text element to the Section having font styled by default...
100
100
$section->addText(
101
- htmlspecialchars('"Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning." (Albert Einstein)')
101
+ htmlspecialchars(
102
+ '"Learn from yesterday, live for today, hope for tomorrow. '
103
+ . 'The important thing is not to stop questioning." '
104
+ . '(Albert Einstein)'
105
+ )
102
106
);
103
107
104
108
/*
105
- * Note: it is possible to customize font style of the Text element you add in three ways:
109
+ * Note: it's possible to customize font style of the Text element you add in three ways:
106
110
* - inline;
107
111
* - using named font style (new font style object will be implicitly created);
108
112
* - using explicitly created font style object.
109
113
*/
110
114
111
115
// Adding Text element having font customized inline...
112
116
$section->addText(
113
- htmlspecialchars('"Great achievement is usually born of great sacrifice, and is never the result of selfishness." (Napoleon Hill)'),
117
+ htmlspecialchars(
118
+ '"Great achievement is usually born of great sacrifice, '
119
+ . 'and is never the result of selfishness." '
120
+ . '(Napoleon Hill)'
121
+ ),
114
122
array('name' => 'Tahoma', 'size' => 10)
115
123
);
116
124
117
125
// Adding Text element having font customized using named font style...
118
126
$fontStyleName = 'oneUserDefinedStyle';
119
- $phpWord->addFontStyle($fontStyleName, array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true));
127
+ $phpWord->addFontStyle(
128
+ $fontStyleName,
129
+ array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)
130
+ );
120
131
$section->addText(
121
- htmlspecialchars('"The greatest accomplishment is not in never falling, but in rising again after you fall." (Vince Lombardi)'),
132
+ htmlspecialchars(
133
+ '"The greatest accomplishment is not in never falling, '
134
+ . 'but in rising again after you fall." '
135
+ . '(Vince Lombardi)'
136
+ ),
122
137
$fontStyleName
123
138
);
124
139
@@ -127,7 +142,9 @@ $fontStyle = new \PhpOffice\PhpWord\Style\Font();
127
142
$fontStyle->setBold(true);
128
143
$fontStyle->setName('Tahoma');
129
144
$fontStyle->setSize(13);
130
- $myTextElement = $section->addText(htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)'));
145
+ $myTextElement = $section->addText(
146
+ htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)')
147
+ );
131
148
$myTextElement->setFontStyle($fontStyle);
132
149
133
150
// Saving the document as OOXML file...
@@ -142,8 +159,8 @@ $objWriter->save('helloWorld.odt');
142
159
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
143
160
$objWriter->save('helloWorld.html');
144
161
145
- /* Note: RTF was skipped here , because the format is not XML-based and requires a bit different example. */
146
- /* Note: PDF was skipped here , because we use "HTML-to-PDF" approach to create PDF documents. */
162
+ /* Note: RTF was skipped, because it's not XML-based and requires a different example. */
163
+ /* Note: PDF was skipped, because we use "HTML-to-PDF" approach to create PDF documents. */
147
164
```
148
165
:warning : Escape any string you pass to OOXML/ODF/HTML document, otherwise it may get broken.
149
166
0 commit comments