PHPOffice / PHPWord

A pure PHP library for reading and writing word processing documents
https://phpoffice.github.io/PHPWord/
Other
7.26k stars 2.7k forks source link

Merge multiple docx files #364

Open jp-morvan opened 10 years ago

jp-morvan commented 10 years ago

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!](https://www.bountysource.com/issues/4284424-merge-multiple-docx-files?utm_campaign=plugin&utm_content=tracker%2F323108&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F323108&utm_medium=issues&utm_source=github).
jp-morvan commented 10 years ago

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 !

wdog commented 9 years ago

it is now possible to merge 2 or more documents?

mariahaubner commented 8 years ago

friendly bump :)

arcanedev-maroc commented 8 years ago

Please, somebody give us a response/solution !

I want to merge multiple docx files into one file.

Ventto commented 8 years ago

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

EasySoftwarePoland commented 8 years ago

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

sambenne commented 7 years ago

Bump, is anything like this possible yet?

troosan commented 6 years ago

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

PavelZurek commented 6 years ago

+1

Jv1i3n commented 6 years ago

I proposed a solution on this pull request

SomayaMomtaz commented 6 years ago

i'm asking the same question https://github.com/PHPOffice/PHPWord/issues/1333

chrisribe commented 5 years ago

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

noukaza commented 4 years ago

i'm asking the same question