Is there a way to import multiple docx into the same document?

Feb 15, 2012 at 2:43 PM
Edited Feb 15, 2012 at 2:43 PM

I am trying to create a "mail merge" and I'm running into an issue. At first I had my code generate multiple .docx files based on templates and that worked fine. However I can't find an easy way to take all of those docx files and convert them to 1 pdf to be able to be printed. So now I'm trying another method and I'm not having luck. I am trying to import multiple docx files into one PHPWord file. The code is something like this:

 

 

$PHPWord = new PHPWord();

foreach ($_POST['survey'] as $key => $value) {
$section = $PHPWord->createSection();
$document = $PHPWord->loadTemplate('../images/uploaded/word/'. $survey_type[$value]);
$document->setValue('date', $the_date);
$document->setValue('clientname1', $client_name);
$section->addPageBreak;


}
$document->save('../images/uploaded/tmp/test.docx');

 

However that still only makes one page. Am I doing something wrong with the createSection? Or can PHPWord not do this?

Anyone have a solution for this?

Sep 7, 2012 at 10:54 AM

$section->addPageBreak();