Forum


Replies: 1   Views: 2589
Dynamic variables with mergedocx
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by gothamdigitalscience  · 07-06-2017 - 18:51

Is it possible to pass in dynamic variables to the mergeDocx function?  Whenever I do (without adding an actual filename) I get an error.  PHP Fatal error:  Uncaught exception 'Exception' with message 'Error while trying to open the (base) template as a zip file'

I'd like to do something like this, where I control the actual documents (with conditionals that I will add later).

require_once ('../phpdocx-advanced-7.0/classes/MultiMerge.inc');
$intro = new CreateDocxFromTemplate('base.docx');

$test1 = new CreateDocxFromTemplate('test1.docx');
$test2 = new CreateDocxFromTemplate('test2.docx');

$merge = new MultiMerge();
$merge->mergeDocx($intro, array($test1,$test2), 'sample.docx', array('mergeType' => '1'));