From dd5e20e7e5d6688deff24abca940e84e4e99ed13 Mon Sep 17 00:00:00 2001 From: Gabriel Bull Date: Wed, 11 Dec 2013 16:17:53 -0500 Subject: [PATCH] Moved image example to README.md --- Examples/Image.php | 24 ------------------------ README.md | 33 ++++++++++++++++++++++++++++++++- changelog.txt | 3 ++- 3 files changed, 34 insertions(+), 26 deletions(-) delete mode 100644 Examples/Image.php diff --git a/Examples/Image.php b/Examples/Image.php deleted file mode 100644 index 8362a2dc..00000000 --- a/Examples/Image.php +++ /dev/null @@ -1,24 +0,0 @@ -createSection(); - -// Add image elements -$section->addImage('_mars.jpg'); -$section->addTextBreak(2); - -$section->addImage('_earth.JPG', array('width'=>210, 'height'=>210, 'align'=>'center')); -$section->addTextBreak(2); - -$section->addImage('_mars.jpg', array('width'=>100, 'height'=>100, 'align'=>'right')); - - - -// Save File -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); -$objWriter->save('Image.docx'); -?> \ No newline at end of file diff --git a/README.md b/README.md index cac0d119..1a5911de 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,6 @@ the following lines to your ``composer.json``. The following is a basic example of the PHPWord library. ```php -// Create a new PHPWord Object $PHPWord = new PHPWord(); // Every element you want to append to the word document is placed in a section. So you need a section: @@ -59,3 +58,35 @@ $myTextElement->setSize(22); $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('helloWorld.docx'); ``` + +## Image + +You can add images easily using the following example. + +```php +$section = $PHPWord->createSection(); +$section->addImage('mars.jpg'); +``` + +Images settings include: + * ``width`` width in pixels + * ``height`` height in pixels + * ``align`` image alignment, __left__, __right__ or __center__ + * ``marginTop`` top margin in inches, can be negative + * ``marginLeft`` left margin in inches, can be negative + * ``wrappingStyle`` can be inline, __square__, __tight__, __behind__, __infront__ + + To add an image with settings, consider the following example. + + ```php +$section->addImage( + 'mars.jpg', + array( + 'width' => 100, + 'height' => 100, + 'marginTop' => -1, + 'marginLeft' => -1, + wrappingStyle => 'behind' + ) +); + ``` diff --git a/changelog.txt b/changelog.txt index abd7d3da..288aab24 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,2 +1,3 @@ 2013-12-11 (v1.0): -- Feature: (gavroche) Added composer file \ No newline at end of file +- Feature: (gavroche) Added composer file +- Feature: (gavroche) Added support for image wrapping style \ No newline at end of file