Replies: 5   Views: 4154
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 !