Forum


Replies: 5   Views: 4240
Merging/adding the same template several times and then replacing the variables
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 livevil  · 25-06-2014 - 15:24

Hi, I'm currently testing the trial version and I'm looking for a way to achieve the following: I have a template page containing several variables (mostly a title, a table and an image). I need to insert several times this template page and then, for each page, replacing the variables according to my data (e.g.: first page get "Title 1", the table get the "data1" dataset and the image is replaced by "Image1.jpg"; then second page get "Title 2", ...) I don't want to generate the title, table and image (by using addText, addTable, ...) since there are other things around that do not need to be modified and it will become to complex (I need to be able to modify the template without recoding everything) Is there a simple way to achieve that (other than using $docx->addExternalFile several times to create the pages I need, saving it to a new .docx and then reopening it as a template in order to replace the variables) ? I hope I was clear enough, not really easy to explain. Thank you in advance for your answer !

Posted by admin  · 26-06-2014 - 08:05

Hi, Corporate and Enterprise licenses have a MultiMerge class to merge DOCX/PDF files. So it's the best choice to do what you need. Regards.

Posted by livevil  · 26-06-2014 - 09:09

Thanks for the answer. So with the Multimerge, you can merge several docx as a unique template and then replace the variables (each of them coming from the individual documents) ?

Posted by admin  · 26-06-2014 - 09:48

Hello, Yes, you can merge DOCX files as a unique template and replace the variables. Regards.

Posted by livevil  · 26-06-2014 - 10:09

Thanks for the info ! I suppose this feature cannot be tested in the demo version ...

Posted by admin  · 26-06-2014 - 12:09

Hello, Sorry but there's no demo available for Corporate and Enterprise licenses. Regards.