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 $header = $section->createHeader();
13 $table = $header->addTable();
15 $table->addCell(3000)->addText('This is the header.', array('align'=>'right') , array('align'=>'right'));
16 $table->addCell(5000)->addImage('_earth.JPG', array('width'=>50, 'height'=>50, 'align'=>'right'));
19 $footer = $section->createFooter();
20 $footer->addPreserveText('Page {PAGE} of {NUMPAGES}.', array('align'=>'right'));
23 $section->addTextBreak();
24 $section->addText('Some text...');
27 require_once __DIR__ . '/../Writer/IOFactory.php';
28 $objWriter = Document_Word_Writer_IOFactory::createWriter($PHPWord, 'Word2007');
29 $objWriter->save('/tmp/HeaderFooter.docx');
30 $fn = '/tmp/HeaderFooter.docx';
31 if (file_exists($fn)) {
32 echo 'Prepare for download!!';
33 header('Content-Description: File Transfer');
34 header('Content-Type: application/octet-stream');
35 header('Content-Disposition: attachment; filename='.basename($fn));
36 header('Content-Transfer-Encoding: binary');
38 header('Cache-Control: must-revalidate');
39 header('Pragma: public');
40 header('Content-Length: ' . filesize($fn));