2014-03-11 02:43:04 +07:00
|
|
|
<?php
|
2014-03-15 22:39:57 +07:00
|
|
|
include_once 'Sample_Header.php';
|
2014-03-11 02:43:04 +07:00
|
|
|
|
2014-03-11 16:27:42 +07:00
|
|
|
// Read contents
|
2014-03-12 21:55:20 +07:00
|
|
|
$name = basename(__FILE__, '.php');
|
|
|
|
|
$source = "resources/{$name}.docx";
|
2014-03-23 10:32:08 +04:00
|
|
|
echo date('H:i:s'), " Reading contents from `{$source}`", \EOL;
|
|
|
|
|
$phpWord = \PhpOffice\PhpWord\IOFactory::load($source);
|
2014-03-11 02:43:04 +07:00
|
|
|
|
2014-03-12 21:55:20 +07:00
|
|
|
// (Re)write contents
|
|
|
|
|
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
|
|
|
|
|
foreach ($writers as $writer => $extension) {
|
2014-03-23 10:32:08 +04:00
|
|
|
echo date('H:i:s'), " Write to {$writer} format", \EOL;
|
|
|
|
|
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
|
2014-03-19 11:04:48 +04:00
|
|
|
$xmlWriter->save("{$name}.{$extension}");
|
2014-03-12 21:55:20 +07:00
|
|
|
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
|
|
|
|
|
}
|
2014-03-11 16:27:42 +07:00
|
|
|
|
2014-03-15 22:39:57 +07:00
|
|
|
include_once 'Sample_Footer.php';
|