Skip to content

Commit 712e09a

Browse files
committed
Basic README for addText and createTextRun
1 parent 34d9121 commit 712e09a

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ the following lines to your ``composer.json``.
3838
2. [Sections](#sections)
3939
* [Section settings](#section-settings)
4040
* [Section page numbering](#section-page-numbering)
41-
3. [Tables](#tables)
41+
3. [Texts](#texts)
42+
4. [Tables](#tables)
4243
* [Cell Style](#tables-cell-style)
43-
4. [Images](#images)
44+
5. [Images](#images)
4445

4546
<a name="basic-usage"></a>
4647
#### Basic usage
@@ -158,6 +159,27 @@ $section = $PHPWord->createSection();
158159
$section->getSettings()->setPageNumberingStart(1);
159160
```
160161

162+
<a name="texts"></a>
163+
#### Texts
164+
165+
Text can be added by using `addText` and `createTextRun` method. `addText` is used for creating simple paragraphs that only contain texts with the same style. `createTextRun` is used for creating complex paragraphs that contain text with different style (some bold, other italics, etc) or other elements, e.g. images or links.
166+
167+
`addText` sample:
168+
169+
```php
170+
$fontStyle = array('name' => 'Times New Roman', 'size' => 9);
171+
$paragraphStyle = array('align' => 'both');
172+
$section->addText('I am simple paragraph', $fontStyle, $paragraphStyle);
173+
```
174+
175+
`createTextRun` sample:
176+
177+
```php
178+
$textrun = $section->createTextRun();
179+
$textrun->addText('I am bold', array('bold' => true));
180+
$textrun->addText('I am italic, array('italic' => true));
181+
$textrun->addText('I am colored, array('color' => 'AACC00'));
182+
```
161183
<a name="tables"></a>
162184
#### Tables
163185

0 commit comments

Comments
 (0)