Forum


Replies: 11   Views: 4558
Headers being added in merge
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 ellytronic  · 20-03-2014 - 08:15

Hi there,



I'm trying to merge two files together using the Pro+ version. One file has headers & footers, the other does not. It all works fine if I merge the file without headers and footers as the first file, but if it's added after the file with headers & footers, it inherits those as well. I'm using enforceSectionPageBreaks (on) and mergeType = 0.



$mergeOptions = array(

  'mergeType' => 0, 

  'enforceSectionPageBreak' => true

);

$docxUtil->mergeDocx( $existing_file, $file_to_append, $new_docx_filename, $mergeOptions );



You can see the files on my server:



original with headers   |   original without headers   |   merged file with problem headers (page 2 should have no headers/footers).





I've spent over 10 hours just trying to solve this problem trying various operations on createdocx but I just can't figure this out. Please help! 


Posted by ellytronic  · 23-03-2014 - 19:37

Hello - any help with this? The support team mentioned when I bought the product if it doesn't work I can get a refund. I'd really just rather get this operational!


Posted by jorgelj  · 24-03-2014 - 09:21

Hello,



We're checking your issue.



Regards.


Posted by jorgelj  · 24-03-2014 - 09:37

Hello,



Word needs headers and footers to do the merge. Please add empty header and footer and it must work fine.



Regards.


Posted by ellytronic  · 25-03-2014 - 22:22

That's exactly what I needed to know. Thanks!


Posted by legalvision  · 22-09-2015 - 01:02

We have the same problem here. We want to add a document at the end, with its headers if it has some, or with no headers if it has none. I understand we need to add blank headers if we don't want the merged documents to inherit headers. But how can I know the merged documents have headers or not (so I can know if I need to add blank headers or not)? Is there a function for this?

Posted by admin  · 22-09-2015 - 07:08

Hello, How are you generating DOCX documents without headers? Word adds empty headers and footers in every DOCX. Regards.

Posted by legalvision  · 23-09-2015 - 01:57

Then I don't really understand why the headers of the core documents are inherited by the merged documents. Could you please tell me what are the correct parameters to use if I want to use multimerge to add documents at the end of the core file, but don't add the headers of the core file into the merged files? I'm currently using a core file of my own, and trying to add some of your examples files at the end of it. All your examples are displayed with my file's headers. Thanks in advance.

Posted by admin  · 23-09-2015 - 14:17

Hello, To avoid adding headers of the first document to be merged, you need to replace or remove them. To do this you can use the importHeadersAndFooters method using a DOCX with empty headers and footers. Other approach is to make public this method: private function removeHeadersAndFooters() in the CreateDocx.inc, that removes both contents. Regards.

Posted by legalvision  · 24-09-2015 - 03:51

Excuse my question, but I'm not sure to understand. If I remove any header, I will lose some headers. Just a quick example : File 1: ## Header1 ## ## Body1 ## File 2: ## Header2 ## ## Body2 ## When I do a MultiMerge, I get this file: ## Header1 ## ## Body1 ## ## Header1 ## ## Body2 ## But I want to get this file: ## Header1 ## ## Body1 ## ## Header2 ## ## Body2 ## If I correctly understand what you say, I could have this file: ## Header1 ## ## Body1 ## ## Blank header ## ## Body2 ## Or even ## Blank header ## ## Body1 ## ## Header2 ## ## Body2 ## But I want to simply attach X files together, without changing anything in each of these files. Is it possible? Thanks for your help :-)

Posted by admin  · 24-09-2015 - 09:31

Hello, OK, I understand. Please try setting the mergeType option as 0 and as 1. If it doesn't work please send both documents to contact[at]phpdocx.com and we'll check them. Regards.

Posted by admin  · 08-10-2015 - 07:25

Hello,
 
The problem comes from the first template and how Word works with headers and footers. By default Word adds headers and footers in all pages and you need to set where you want to add or not them. You can change headers and footers adding new sections.
 
To solve this issue you have two approachs:
 
1. Do an intermediate merge to add a new DOCX with the new section that doesn't include any header nor footer.
 
2. Add in your first template a new section that doesn't include the header and use the mergeType as 1.
 
This page explains how to delete a header or footer from a single page:
 
 
Regards.