Forum


Replies: 1   Views: 2611
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 admin  · 08-06-2017 - 06:17

Hello,

Since phpdocx 7, Premium licenses allow in-memory merging, but the Advanced license only allow to merge files. Using an Advanced license, you need to create the DOCX files and then merge them.
 
An in-memory merging sample using phpdocx 7 Premium is the following:
<?php

require_once 'classes/MultiMerge.inc';

CreateDocx::$returnDocxStructure = true;

// create the first document to be merged and return it as DOCX structure
$docx_a = new CreateDocx();

$text = 'Lorem ipsum dolor sit amet';

$docx_a->addText($text);

$document1 = $docx_a->createDocx();

// create the second document to be merged and return it as DOCX structure
$docx_b = new CreateDocx();

$text = 'Excepteur sint occaecat cupidatat non proident.';

$docx_b->addText($text);

$document2 = $docx_b->createDocx();

CreateDocx::$returnDocxStructure = false;

$merge = new MultiMerge();
$merge->mergeDocx($document1, array($document2), 'example_merge_docx_2.docx', array());

It can use CreateDocx and CreateDocxFromTemplate.

Regards.