@@ -6,12 +6,13 @@ General usage
66Basic example
77-------------
88
9- The following is a basic example of the PHPWord library. More examples
9+ The following is a basic example of the PhpWord library. More examples
1010are provided in the `samples folder <https://github.com/PHPOffice/PHPWord/tree/master/samples/ >`__.
1111
1212.. code-block :: php
1313
14- require_once '../src/PhpWord/PhpWord.php';
14+ require_once 'src/PhpWord/Autoloader.php';
15+ PhpOffice\PhpWord\Autoloader::register();
1516
1617 $phpWord = new \PhpOffice\PhpWord\PhpWord();
1718
@@ -34,17 +35,23 @@ are provided in the `samples folder <https://github.com/PHPOffice/PHPWord/tree/m
3435 'myOwnStyle');
3536
3637 // You can also put the appended element to local object like this:
37- $fontStyle = new PHPWord_Style_Font ();
38+ $fontStyle = new \PhpOffice\PhpWord\Style\Font ();
3839 $fontStyle->setBold(true);
3940 $fontStyle->setName('Verdana');
4041 $fontStyle->setSize(22);
4142 $myTextElement = $section->addText('Hello World!');
4243 $myTextElement->setFontStyle($fontStyle);
4344
4445 // Finally, write the document:
45- $objWriter = PHPWord_IOFactory ::createWriter($phpWord, 'Word2007');
46+ $objWriter = \PhpOffice\PhpWord\IOFactory ::createWriter($phpWord, 'Word2007');
4647 $objWriter->save('helloWorld.docx');
4748
49+ $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText');
50+ $objWriter->save('helloWorld.odt');
51+
52+ $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'RTF');
53+ $objWriter->save('helloWorld.rtf');
54+
4855 Default font
4956------------
5057
@@ -82,19 +89,19 @@ Measurement units
8289The base length unit in Open Office XML is twip. Twip means "TWentieth
8390of an Inch Point", i.e. 1 twip = 1/1440 inch.
8491
85- You can use PHPWord helper functions to convert inches, centimeters, or
92+ You can use PhpWord helper functions to convert inches, centimeters, or
8693points to twips.
8794
8895.. code-block :: php
8996
9097 // Paragraph with 6 points space after
9198 $phpWord->addParagraphStyle('My Style', array(
92- 'spaceAfter' => PHPWord_Shared_Font ::pointSizeToTwips(6))
99+ 'spaceAfter' => \PhpOffice\PhpWord\Shared\Font ::pointSizeToTwips(6))
93100 );
94101
95102 $section = $phpWord->createSection();
96103 $sectionStyle = $section->getSettings();
97104 // half inch left margin
98- $sectionStyle->setMarginLeft(PHPWord_Shared_Font ::inchSizeToTwips(.5));
105+ $sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Font ::inchSizeToTwips(.5));
99106 // 2 cm right margin
100- $sectionStyle->setMarginRight(PHPWord_Shared_Font ::centimeterSizeToTwips(2));
107+ $sectionStyle->setMarginRight(\PhpOffice\PhpWord\Shared\Font ::centimeterSizeToTwips(2));
0 commit comments