Reputation: 61
I'm trying to read a docx file using PHPWord, but i'm getting the following error. I can't seem to find a solution to this anywhere:
PHP Fatal error: Uncaught exception 'PhpOffice\PhpWord\Exception\Exception' with message '"Word2007" is not a valid Reader.'
This is the PHP code to load the file:
$phpWord = \PhpOffice\PhpWord\IOFactory::load($filepath1);
$xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF');
Any help would be greatly appreciated!
Upvotes: 0
Views: 1990
Reputation: 154
Method 1:-
$reader = \PhpOffice\PhpWord\IOFactory::createReader("Word2007");
$phpWord = $reader->load($file);
$writer = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, "PDF");
$writer->save('example.pdf');
For more info visit :- https://github.com/PHPOffice/PHPWord
Upvotes: -2