I am working with templates and want to make a batch file of more documents. For example we've got 50 letters for different persons. We don't want to press a button 50 times to download and print each document seperatly. We want to merge those 50 documents into one document and download it to print it at once. I've got a page number in the template footer.
For now i use the method addDOCX to combine more documents. So first i will generate a docx file for each template and later on i will combine everything with the addDOCX method. Each genereted docx files has 2 pages. Page numbering is working fine for now for each document.
But when I combine 50 of these seperate documents with the addDOCX method, the last page has page number 100. I was hoping for a possibility to merge more documents and keep exactly the format of those documents. So the first page of the merged document has pagenumber 1, the second page pagenumber 2. But the 3th page has pagenumber 1 again. (this is the first page of the secong docx file) and so on.
So i want to merge more documents in one document only to make printing easier and faster for the end user.
Has anybody a good solution?
example code:
---------------------------------------------
[code]
...
//includes for dbase, phpdocx etc.
$oDatabase->Query("SELECT `ID`, `templateFileName`, `name` FROM `Docs` WHERE `printed` = false LIMIT 50 ");
//loop 50 documents and make a docx file for each record.
while($aDocs = $oDatabase->NextRow())
{
$oDocx = new CreateDocx();
$oDocx->addTemplate($aDocs["templateFileName"]); //the template has 2 pages
$oDocx->addTemplateVariable('varname', $aDocs["name"]);
$oDocx->createDocx($aDocs["ID"].'-generateddoc');
//save the ID's of the documents we have generated in this batch
$aGeneratedDocID[] = $aDocs["ID"];
}
//loop the documents ID's and make one file.
$oDocx = new CreateDocx();
foreach($aGeneratedDocID AS $iDocNumber)
{
$oDocx->addDOCX($iDocNumber . 'generateddoc.docx');
$oDocx->addBreak('page');
}
$oDocx->createDocx('batchfile');
//for testing purpose i didn't cleanup the code. I could use a second docx object to combine the documents in the first while loop instead of using the $aGeneratedDocID variabele.
[/code]
[b]Result[/b]
a batchfile.docx with 50 seperate documents (for seperate customers) with page numbering till 100. and not 1,2,1,2,1,2 and so on.
Is there a solution?