File_Convert_AbiToDocx/AbiToDocx.php
[pear-examples] / File_Convert_AbiToDocx / AbiToDocx.php
1 <?php
2 ini_set('include_path', __DIR__  . '/../pear:.');
3 require_once 'File/Convert/AbiToDocx.php';
4
5 //Example AbiWord file
6 $abiFileName = '/tmp/thumb2.abw';
7 $fn = '/tmp/thumb.docx';
8 $conv = new File_Convert_AbiToDocx($abiFileName);
9 $conv->save($fn);
10 //$xml = new XMLReader();
11
12 // Download the file for testing
13 if($_SERVER['SERVER_NAME'] == 'localhost')
14 {
15     exit;
16 }
17 if (file_exists($fn)) {
18     echo 'Prepare for download!!';
19     header('Content-Description: File Transfer');
20     header('Content-Type: application/octet-stream');
21     header('Content-Disposition: attachment; filename='.basename($fn));
22     header('Content-Transfer-Encoding: binary');
23     header('Expires: 0');
24     header('Cache-Control: must-revalidate');
25     header('Pragma: public');
26     header('Content-Length: ' . filesize($fn));
27     ob_clean();
28     flush();
29     readfile($fn);
30     exit;
31 }
32
33
34 ?>