Skip to content

Commit fa7f2cd

Browse files
author
Roman Syroeshko
committed
https://github.com/PHPOffice/PHPWord/issues/51
1 parent 2cb124f commit fa7f2cd

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

README.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,27 +98,42 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
9898
$section = $phpWord->addSection();
9999
// Adding Text element to the Section having font styled by default...
100100
$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+
)
102106
);
103107

104108
/*
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:
106110
* - inline;
107111
* - using named font style (new font style object will be implicitly created);
108112
* - using explicitly created font style object.
109113
*/
110114

111115
// Adding Text element having font customized inline...
112116
$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+
),
114122
array('name' => 'Tahoma', 'size' => 10)
115123
);
116124

117125
// Adding Text element having font customized using named font style...
118126
$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+
);
120131
$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+
),
122137
$fontStyleName
123138
);
124139

@@ -127,7 +142,9 @@ $fontStyle = new \PhpOffice\PhpWord\Style\Font();
127142
$fontStyle->setBold(true);
128143
$fontStyle->setName('Tahoma');
129144
$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+
);
131148
$myTextElement->setFontStyle($fontStyle);
132149

133150
// Saving the document as OOXML file...
@@ -142,8 +159,8 @@ $objWriter->save('helloWorld.odt');
142159
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
143160
$objWriter->save('helloWorld.html');
144161

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. */
147164
```
148165
:warning: Escape any string you pass to OOXML/ODF/HTML document, otherwise it may get broken.
149166

0 commit comments

Comments
 (0)