From 712e09a2e55e15e9b03d032ee5cb0b6cd8330a84 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 9 Mar 2014 22:43:35 +0700 Subject: [PATCH] Basic README for `addText` and `createTextRun` --- README.md | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 111070fd..2f02013e 100755 --- a/README.md +++ b/README.md @@ -38,9 +38,10 @@ the following lines to your ``composer.json``. 2. [Sections](#sections) * [Section settings](#section-settings) * [Section page numbering](#section-page-numbering) -3. [Tables](#tables) +3. [Texts](#texts) +4. [Tables](#tables) * [Cell Style](#tables-cell-style) -4. [Images](#images) +5. [Images](#images) #### Basic usage @@ -158,6 +159,27 @@ $section = $PHPWord->createSection(); $section->getSettings()->setPageNumberingStart(1); ``` + +#### Texts + +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. + +`addText` sample: + +```php +$fontStyle = array('name' => 'Times New Roman', 'size' => 9); +$paragraphStyle = array('align' => 'both'); +$section->addText('I am simple paragraph', $fontStyle, $paragraphStyle); +``` + +`createTextRun` sample: + +```php +$textrun = $section->createTextRun(); +$textrun->addText('I am bold', array('bold' => true)); +$textrun->addText('I am italic, array('italic' => true)); +$textrun->addText('I am colored, array('color' => 'AACC00')); +``` #### Tables