@@ -32,7 +32,6 @@ the following lines to your ``composer.json``.
32
32
The following is a basic example of the PHPWord library.
33
33
34
34
``` php
35
- // Create a new PHPWord Object
36
35
$PHPWord = new PHPWord();
37
36
38
37
// 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);
59
58
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
60
59
$objWriter->save('helloWorld.docx');
61
60
```
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
+ ```
0 commit comments