Hello,
Please note that importContents uses MultiMerge internally using in-memory documents (https://www.phpdocx.com/documentation/cookbook/in-memory-docx-documents) to avoid generating extra files.
Using importContents, you can avoid importing specific elements using a custom XPath query. For example internal sections:
$referenceNode = array(
'customQuery' => '//w:body/*[not(self::w:p/w:pPr/w:sectPr)]',
);
$docx->importContents('document.docx', $referenceNode);
But we think the easiest approach would be importing all contents to the DOCX and then use importHeadersAndFooters (https://www.phpdocx.com/api-documentation/layout-and-general/import-headers-and-footers-Word-document-with-PHP) to set headers and footers as the first DOCX.
If the contents to be imported doesn't include external relationships (such as images or charts), an alternative approach can be done getting the XML of the contents with getDocxPathQuery (https://www.phpdocx.com/api-documentation/docx-path/get-docx-path-query-info) and adding them using addWordML (https://www.phpdocx.com/api-documentation/word-content/add-raw-wordml-Word-document).
If you send to contact[at]phpdocx.com two or three sample DOCX documents we'll check them to generate a custom script.
Regards.