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.
Hi,
I am trying to do a Mail Merge for about 1,000 letters. All letters are based on the same template and vary only slightly based on the template variables.
If I have a naive loop then the whole process takes a very long time (measured in minutes) -
for(0...1000)
{
$document = new \CreateDocxFromTemplate($templatePath);
$document->replaceVariableByText($data);
$document->createDocx($targetPath);
}
Ideally I would like to load the template once outside of the loop, and then override variables inside the loop which should be quite fast. But I couldn't find a recommended way to speed this up, and just using "clone" does not get the job done.
How can I efficiently and quickly generate many docx files if they are based on the same template?
Hello,
The BatchTemplateProcessing class included in the Enterprise license is the best solution, as it gets the best performance.
Please send us the document (http://www.phpdocx.com/contact) and we'll run it to get the performance.
Regards.