Forum


Replies: 5   Views: 5230
Merge documents and/or templates
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 nicolas  · 11-04-2013 - 12:12

Hi,

Indeed, PHPDOCX 2.3 can insert DOCX document inside another:
[code]$docx->addDOCX('../files/Text.docx');[/code]

However, it is not possible to add a DOCX template inside the DOCX document that we are developping :'(
I tried :
[code]
$docx = new CreateDocx();
$docx->setEncodeUTF8();
$docx->addText(’First content’);
$docx->addDOCX('template_test.docx');
$docx->addTemplateVariable('VAR1', 'value1');
$docx->addTemplateVariable('VAR2', 'value2');
$docx->addTemplateVariable('VAR3', 'Value3);
$docx->addText(’Second content’);[/code]
but the template variables are not replaced.

I also tried:
[code]
$docx = new CreateDocx();
$docx->setEncodeUTF8();
$docx->addText(’First content’);
$docx->addTemplate('template_test.docx');
$docx->addTemplateVariable('VAR1', 'value1');
$docx->addTemplateVariable('VAR2', 'value2');
$docx->addTemplateVariable('VAR3', 'Value3);
$docx->addText(’Second content’);[/code]

The template variables are well replaced but only the DOCX template is present in the current DOCX document we are developping...

Any help would be appreciated