Forum


Replies: 5   Views: 287
Importcontents only for body, not for header/footer
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 admin  · 09-11-2023 - 18:10

Hello,

The importContents method imports contents from an external DOCX. If no referenceNode is set, all contents are imported. This method is useful when importing specific contents (or exclude specific contents if needed using a custom XPath query).

If you neeed to import all contents, we recommend you use mergeDocx (https://www.phpdocx.com/api-documentation/docxutilities/merge-Word-documents-with-PHP). Setting the mergeType option you can preserve or ignore the sections (that also include the headers and footer):

0: preserves the sections of the merged document with their respective headers and footers.
1: merges the contents at the end of the last section of the first document.

If you set mergeType as 1, sections from the merged DOCX are ignored, and contents are added at the end of the last section of the first document. Maybe this method is the best approach for your needs.

If you send the DOCX samples to contact[at]phpdocx.com we'll check them to recommend the best approack for your task.

Regards.