Forum


Replies: 1   Views: 203
Merging documents overlaps header part
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by anushkapachpute  · 28-05-2024 - 07:38

Hello

Actually I am trying to merge 2 documents. Before merging these documents looks fine. But when I try to merge it, after merge it gets disturbed. Like header part is disturbed merged output. I have also added part of my code.

  $coverPagePDF = $INPUT_DIRECTORY . 'cover.docx';
   $indexPagePDF = $INPUT_DIRECTORY . 'glossary.docx';


 if (file_exists($coverPagePDF)) {
        mLog("Cover Page found. Adding to merge process\n");
        $mergeResult = $merge->mergeDocx($coverPagePDF, array(), $OUTPUT_DIRECTORY . $OUTPUT_FILE, array('mergeType' => 0));
        if (!$mergeResult) {
            mLog("Merge failed for cover page\n");
            return;
        }
        $filesAdded[] = $coverPagePDF;
    } else {
        mLog("Cover Page not found\n");
    }

    // Merge index page separately if it exists
    if (file_exists($indexPagePDF)) {
        mLog("Glossary Page found. Adding to merge process\n");
        $mergeResult = $merge->mergeDocx($OUTPUT_DIRECTORY . $OUTPUT_FILE, array($indexPagePDF), $OUTPUT_DIRECTORY . $OUTPUT_FILE, array('mergeType' => 0));
        if (!$mergeResult) {
            mLog("Merge failed for Glossary page\n");
            return;
        }
        $filesAdded[] = $indexPagePDF;
    } else {
        mLog("Glossary Page not found\n");
    }