2 ini_set('include_path', __DIR__ . '/../../..:.');
3 require_once __DIR__ . '/../Writer.php';
6 $PHPWord = new Document_Word_Writer();
8 // New portrait section
9 $section = $PHPWord->createSection();
12 //$section->addImage('_mars.jpg');
13 //$section->addTextBreak(2);
14 $section->addText('Below is earth image!');
15 $section->addTextBreak(2);
16 $section->addImage('_earth.JPG', array('width'=>500, 'height'=>500));
17 $section->addTextBreak(2);
18 $section->addText('Above is earth image!');
19 //$section->addImage('_mars.jpg');
21 // add in /tmp/67219.0.jpg
22 //$rid = $section->addImageDefered('_earth.JPG', array('width'=>210, 'height'=>210, 'align'=>'center'));
23 // store map [67219.0] = $rid
25 // when get image - > lookup map [67219.0] for rid
26 //$section->addImageToCollection($rid, '_earth.JPG'); // 67219.0.jpg/:;:
27 $fn = '/tmp/Image.docx';
29 require_once __DIR__ . '/../Writer/IOFactory.php';
30 $objWriter = Document_Word_Writer_IOFactory::createWriter($PHPWord, 'Word2007');
31 $objWriter->save($fn);
32 // Download the file for testing
33 if($_SERVER['SERVER_NAME'] == 'localhost')
37 if (file_exists($fn)) {
38 echo 'Prepare for download!!';
39 header('Content-Description: File Transfer');
40 header('Content-Type: application/octet-stream');
41 header('Content-Disposition: attachment; filename='.basename($fn));
42 header('Content-Transfer-Encoding: binary');
44 header('Cache-Control: must-revalidate');
45 header('Pragma: public');
46 header('Content-Length: ' . filesize($fn));