@@ -40,6 +40,7 @@ Don't forget to change `code::` directive to `code-block::` in the resulting rst
40
40
- [ RTF] ( #rtf )
41
41
- [ HTML] ( #html )
42
42
- [ PDF] ( #pdf )
43
+ - [ Recipes] ( #recipes )
43
44
- [ Frequently asked questions] ( #frequently-asked-questions )
44
45
- [ References] ( #references )
45
46
@@ -929,6 +930,44 @@ To be completed.
929
930
930
931
To be completed.
931
932
933
+ # Recipes
934
+
935
+ ## Create float left image
936
+
937
+ Use absolute positioning relative to margin horizontally and to line vertically.
938
+
939
+ ``` php
940
+ $imageStyle = array(
941
+ 'width' => 40,
942
+ 'height' => 40
943
+ 'wrappingStyle' => 'square',
944
+ 'positioning' => 'absolute',
945
+ 'posHorizontalRel' => 'margin',
946
+ 'posVerticalRel' => 'line',
947
+ );
948
+ $textrun->addImage('resources/_earth.jpg', $imageStyle);
949
+ $textrun->addText($lipsumText);
950
+ ```
951
+
952
+ ## Download the produced file automatically
953
+
954
+ Use ` php://output ` as the filename.
955
+
956
+ ``` php
957
+ $phpWord = new \PhpOffice\PhpWord\PhpWord();
958
+ $section = $phpWord->createSection();
959
+ $section->addText('Hello World!');
960
+ $file = 'HelloWorld.docx';
961
+ header("Content-Description: File Transfer");
962
+ header('Content-Disposition: attachment; filename="' . $file . '"');
963
+ header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
964
+ header('Content-Transfer-Encoding: binary');
965
+ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
966
+ header('Expires: 0');
967
+ $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
968
+ $xmlWriter->save("php://output");
969
+ ```
970
+
932
971
# Frequently asked questions
933
972
934
973
## Is this the same with PHPWord that I found in CodePlex?
0 commit comments