Phpword: Merge multiple docx files

Created on 9 Sep 2014  路  13Comments  路  Source: PHPOffice/PHPWord

Hi,
I'm trying to merge multiple docx files by adding page break in section but the file is always empty.

$document = new \PhpOffice\PhpWord\PhpWord();
$final_document = \PhpOffice\PhpWord\IOFactory::createWriter($document, 'Word2007');
$section = $document->createSection(($i=0));
foreach($files as $file)
{
      $_document = $document->loadTemplate($file);
      $section->addPageBreak();
}
$final_document->save($filename);

Thank you


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Consulting Request Open XML (Word 2007+) Template Processor

Most helpful comment

Just found a simple solution: https://github.com/krustnic/DocxMerge
But it is not working under Libreoffice/Openoffice and word2003

All 13 comments

Hi,
Just to know if it's a bug, if it's not make for or if it's planned to add it to phpword ?
Thank you for this library !

it is now possible to merge 2 or more documents?

_friendly bump_ :)

Please, somebody give us a response/solution !

I want to merge multiple docx files into one file.

It is now possible to merge 2 or more documents like PHPDocx ?

Just found a simple solution: https://github.com/krustnic/DocxMerge
But it is not working under Libreoffice/Openoffice and word2003

Bump, is anything like this possible yet?

Not out of the box. feel free to contribute :-)

+1

I proposed a solution on this pull request

Same here any instructions on how to append existing documents together ?

i'm asking the same question

Was this page helpful?
0 / 5 - 0 ratings