Skip to content

Commit dd5e20e

Browse files
author
Gabriel Bull
committed
Moved image example to README.md
1 parent d8ea62c commit dd5e20e

File tree

3 files changed

+34
-26
lines changed

3 files changed

+34
-26
lines changed

Examples/Image.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ the following lines to your ``composer.json``.
3232
The following is a basic example of the PHPWord library.
3333

3434
```php
35-
// Create a new PHPWord Object
3635
$PHPWord = new PHPWord();
3736

3837
// 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);
5958
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
6059
$objWriter->save('helloWorld.docx');
6160
```
61+
62+
## Image
63+
64+
You can add images easily using the following example.
65+
66+
```php
67+
$section = $PHPWord->createSection();
68+
$section->addImage('mars.jpg');
69+
```
70+
71+
Images settings include:
72+
* ``width`` width in pixels
73+
* ``height`` height in pixels
74+
* ``align`` image alignment, __left__, __right__ or __center__
75+
* ``marginTop`` top margin in inches, can be negative
76+
* ``marginLeft`` left margin in inches, can be negative
77+
* ``wrappingStyle`` can be inline, __square__, __tight__, __behind__, __infront__
78+
79+
To add an image with settings, consider the following example.
80+
81+
```php
82+
$section->addImage(
83+
'mars.jpg',
84+
array(
85+
'width' => 100,
86+
'height' => 100,
87+
'marginTop' => -1,
88+
'marginLeft' => -1,
89+
wrappingStyle => 'behind'
90+
)
91+
);
92+
```

changelog.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
2013-12-11 (v1.0):
2-
- Feature: (gavroche) Added composer file
2+
- Feature: (gavroche) Added composer file
3+
- Feature: (gavroche) Added support for image wrapping style

0 commit comments

Comments
 (0)