Forum


Replies: 5   Views: 3723
Create multiple documents by template?
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 marcushjortsberg  · 09-08-2011 - 02:53

I want to achieve one thing.

I want to make one file that contains several pages, every page should look the same as the others except for some bits of info. I have a template that I try to import and make a foreach loop and create one file, something like

[code]
require_once 'CreateDocx.inc';
$docx = new CreateDocx();
$docx->addTemplate('pink.docx');
foreach ($allthings as $allthing)
{


$docx->addHeader($header, $paramsHeader);

$docx->addTemplateVariable('INFO', $allthing->info);
$docx->addTemplateVariable('INFO"', $allthing->info2);
$docx->addTemplateVariable('CONCATINFO3AND4', $allthing->info3 . ' ' . $allthing->info4);

$docx->addBreak('page');
}
$filename = $allthing->info;
$docx->createDocx($filename);[/code]

but only one page is created...ideas?

Posted by jwiseman  · 11-04-2013 - 12:13

Anyone have an answer for this. I am running into the same issue phpdocx 3.0 on windows

Posted by admin  · 11-04-2013 - 12:13

Hello,

There's an example of that in intermediate/Multidocument.inc file. It's for new documents but it's the same for templates.

Regards.

Posted by marcushjortsberg  · 11-04-2013 - 12:13

Hi again!

I don't know if you missunderstod me or the other way around...

I want to make just ONE file.

I want to make some kind of loop where the template is used over and over again and a new template variable is new for each run...

Hope for this to solve!

Thanx in advance!

Posted by admin  · 11-04-2013 - 12:13

Hello,

UPDATE: BulkProcessing included in Premium licenses is the best approach for this task.


We undertstood you. You need to create as many documents as needed and then merge them to a single document. You can't do it with just one method.

Regards.