0

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!

Ross
  • 66
  • 12
  • are you sure the autoload is working? what's the result of "new PhpOffice\PhpWord\Reader\Word2017();"? – troosan Feb 15 '18 at 21:38
  • `$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF');` -> add a backslash, I'd say – Maria Mar 01 '18 at 16:19
  • @Maria - That didn't work but thank you for the suggestion! – Ross Mar 05 '18 at 07:45
  • Ok, so depending on your PHPWord version, the library is not able to create the Reader in /PhpWord/IOFactory.php::createObject(). so have you included the autoloader correctly (as @troosan said)? Maybe edit your question with a full code example :) – Maria Mar 05 '18 at 11:19

0 Answers0