createSection(); // Add image elements //$section->addImage('_mars.jpg'); //$section->addTextBreak(2); $section->addText('Below is earth image!'); $section->addTextBreak(2); $section->addImage('_earth.JPG', array('width'=>500, 'height'=>500)); $section->addTextBreak(2); $section->addText('Above is earth image!'); //$section->addImage('_mars.jpg'); // add in /tmp/67219.0.jpg //$rid = $section->addImageDefered('_earth.JPG', array('width'=>210, 'height'=>210, 'align'=>'center')); // store map [67219.0] = $rid // when get image - > lookup map [67219.0] for rid //$section->addImageToCollection($rid, '_earth.JPG'); // 67219.0.jpg/:;: $fn = '/tmp/Image.docx'; // Save File require_once __DIR__ . '/../Writer/IOFactory.php'; $objWriter = Document_Word_Writer_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save($fn); // Download the file for testing if($_SERVER['SERVER_NAME'] == 'localhost') { exit; } if (file_exists($fn)) { echo 'Prepare for download!!'; header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($fn)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($fn)); ob_clean(); flush(); readfile($fn); exit; } ?>