Jump to content

Loading A .docx with PHPWord


cloudy243

Recommended Posts

Hi All,

 

Don’t know if any of you have any experience with PHPWord (actually a pretty cool library I stumbled upon), but worth a shot!

 

So either I’m missing something very obvious, or else I just have terrible luck. I am attempting to load a .docx file with PHPWord, set a value in it, and save the file. The issue is the saved file comes out as a blank word document, 7kb in size. The document I put in is large and has multiple pages. Obviously its not loading it right. My code is as follows:

$PHPWord = new \PhpOffice\PhpWord\PhpWord();
$document = $PHPWord->loadTemplate('Resources/documents/test.docx');

$document->setValue('theDate', '2014-07-25');

$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, 'Word2007');
$xmlWriter->save("php://output");

I have tried with multiple test.docx files of different sorts, but the output file is always blank.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.