Forum


Replies: 5   Views: 3016
Merging documents at same time as another mixes output
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  · 16-06-2017 - 18:44

Hello,

Yes, using the mergeDocx you can merge from two to any DOCX documents:

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

As you are using a Premium license, you can do it using in-memory documents (without generating in the fs the DOCX to be merged), as the sample from our previous update does. To use in-memory DOCX, you just need to enable the $returnDocxStructure flag:

CreateDocx::$returnDocxStructure = true;

The DOCX is not created but returned when you call the createDocx method:

$document1 = $docx_a->createDocx();

You can generate and keep in variables as many documents as needed to be stored, merged, serialized...

Do not forget to disable the flag after you have finished creating documents:

CreateDocx::$returnDocxStructure = false;

It uses the memory of the server where PHP runs, this is the web server.

Regards.