DocxMerge icon indicating copy to clipboard operation
DocxMerge copied to clipboard

Merged document only contains first document

Open chromakey opened this issue 9 years ago • 11 comments

I ran the following code using your example as a template:

 <?php
 require("DocxMerge.php");
 $dm = new DocxMerge();
 $dm->merge( [
       "doc2.docx",
       "doc1.docx"
 ], "result.docx" );
?>

result.docx only winds up containing the material from the first docx file (in this case doc2.docx). PHP version 5.5.24 (cli)

chromakey avatar Aug 12 '15 14:08 chromakey

Same problem here.

In Microsoft Word (2007, sorry not tested other) the whole document shows. BUT when you open the docx file with LibreOffice/OpenOffice it only views the first page. When I use the version of Jupiter, with the page breaks, It shows the first page and all the rest of the pages blank.

Say you have a merge of 100 docx files, you only get the first page with content and 99 blank pages.

I tried everything. Can someone take a look at this?

BrutusBossNL avatar Nov 09 '15 08:11 BrutusBossNL

This is a visualisation of how docxmerge works: [xml first-doc] text of the firstdoc [include second-doc.zip /] ... [/xml]

It's not a true merge, just includes. The "include a zip" method isn't supported by LibreOffice or patched Word 2003.

seblangis avatar Dec 16 '15 14:12 seblangis

Is there any solutiuon for that trouble?

dellert avatar Feb 17 '17 06:02 dellert

I found a $599 librarie that does the job.

seblangis avatar Feb 17 '17 11:02 seblangis

Same problem here

        $files = glob($path.'*');
        $dm = new DocxMerge();
        $dm->merge( $files, "uploads/merge/result.docx" );

But return only one file

narendraraghuwanshi avatar Apr 14 '18 12:04 narendraraghuwanshi

+1 For this issue.

nickshatilo avatar May 20 '18 15:05 nickshatilo

Same here

pida42 avatar May 28 '18 08:05 pida42

+1

promisingccy avatar Aug 09 '18 09:08 promisingccy

``krustnic/docx-merge/src/DocxMerge/Docx.php line217

        rename($tempFile, $this->docxPath);

replace with //通过win->虚拟机中的rename产生'Operation not permitted'报错,走copy unlink //不报错 则走rename if(!rename($tempFile, $this->docxPath)){ copy( $tempFile, $this->docxPath ); unlink($tempFile); }

promisingccy avatar Aug 09 '18 12:08 promisingccy

found this solution https://stackoverflow.com/a/7960164/887100

yujin1st avatar Feb 27 '19 15:02 yujin1st

I have done this project https://github.com/JohannCOSTE/phpMergeDocx based of @yujin1st comment. It works for LibreOffice but not for last MS Word version if someone have a solution it would be great!

JohannCOSTE avatar Nov 01 '20 12:11 JohannCOSTE