From fa7f2cdc25b780d580ff5ce43bd8280696802637 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Tue, 9 Dec 2014 21:46:19 +0400 Subject: [PATCH] https://github.com/PHPOffice/PHPWord/issues/51 --- README.md | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e6e0bf77..f0f2ae2e 100644 --- a/README.md +++ b/README.md @@ -98,11 +98,15 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); // Adding Text element to the Section having font styled by default... $section->addText( - htmlspecialchars('"Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning." (Albert Einstein)') + htmlspecialchars( + '"Learn from yesterday, live for today, hope for tomorrow. ' + . 'The important thing is not to stop questioning." ' + . '(Albert Einstein)' + ) ); /* - * Note: it is possible to customize font style of the Text element you add in three ways: + * Note: it's possible to customize font style of the Text element you add in three ways: * - inline; * - using named font style (new font style object will be implicitly created); * - using explicitly created font style object. @@ -110,15 +114,26 @@ $section->addText( // Adding Text element having font customized inline... $section->addText( - htmlspecialchars('"Great achievement is usually born of great sacrifice, and is never the result of selfishness." (Napoleon Hill)'), + htmlspecialchars( + '"Great achievement is usually born of great sacrifice, ' + . 'and is never the result of selfishness." ' + . '(Napoleon Hill)' + ), array('name' => 'Tahoma', 'size' => 10) ); // Adding Text element having font customized using named font style... $fontStyleName = 'oneUserDefinedStyle'; -$phpWord->addFontStyle($fontStyleName, array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)); +$phpWord->addFontStyle( + $fontStyleName, + array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true) +); $section->addText( - htmlspecialchars('"The greatest accomplishment is not in never falling, but in rising again after you fall." (Vince Lombardi)'), + htmlspecialchars( + '"The greatest accomplishment is not in never falling, ' + . 'but in rising again after you fall." ' + . '(Vince Lombardi)' + ), $fontStyleName ); @@ -127,7 +142,9 @@ $fontStyle = new \PhpOffice\PhpWord\Style\Font(); $fontStyle->setBold(true); $fontStyle->setName('Tahoma'); $fontStyle->setSize(13); -$myTextElement = $section->addText(htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)')); +$myTextElement = $section->addText( + htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)') +); $myTextElement->setFontStyle($fontStyle); // Saving the document as OOXML file... @@ -142,8 +159,8 @@ $objWriter->save('helloWorld.odt'); $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML'); $objWriter->save('helloWorld.html'); -/* Note: RTF was skipped here, because the format is not XML-based and requires a bit different example. */ -/* Note: PDF was skipped here, because we use "HTML-to-PDF" approach to create PDF documents. */ +/* Note: RTF was skipped, because it's not XML-based and requires a different example. */ +/* Note: PDF was skipped, because we use "HTML-to-PDF" approach to create PDF documents. */ ``` :warning: Escape any string you pass to OOXML/ODF/HTML document, otherwise it may get broken.