https://www.phpdocx.com/api-documentation/docxutilities/merge-Word-documents-with-PHP
Hi,
Can you please provied a definitive PHP example for all of the options for mergeDocx?
On that page all you provide is array() as the example.
Thanks!
https://www.phpdocx.com/api-documentation/docxutilities/merge-Word-documents-with-PHP
Hi,
Can you please provied a definitive PHP example for all of the options for mergeDocx?
On that page all you provide is array() as the example.
Thanks!
Hello,
The available options are detailed on the page (https://www.phpdocx.com/api-documentation/docxutilities/merge-Word-documents-with-PHP). This page includes a parameters table with all available options, their types, and the documentation: mergeType, enforceSectionPageBreak, numbering, lineBreaks, forceLatestStyles, renameStyles, and importEmbeddedFonts.
The same information is also detailed in the practical guide (https://www.phpdocx.com/documentation/practical/merging Merging DOCX documents section). And the phpdoc documentation included in the class.
For example, to set mergeType as 1:
$merge->mergeDocx('document1.docx', array('document2.docx', 'document3.docx'), 'output.docx', array('mergeType' => 1));
Regards.
Thanks, but I asked for a complete example. I guess after buying multiple licenses I will now spend the time to write and then ask if it is accurate.
array('mergeType' => 1, 'enforceSectionPageBreak' => true, numbering => 'continue', lineBreaks=> 10, forceLatestStyles => true, renameStyles => false, importEmbeddedFonts => false)
Is this accurate?
Hello,
Please note that the options to be added in the mergeDocx method depend on how you want to merge the documents and if you need to change the default values.
For example, if you want to keep existing sections and keep embedded fonts:
$merge->mergeDocx('document1.docx', array('document2.docx', 'document3.docx'), 'output.docx', array('mergeType' => 0, 'importEmbeddedFonts' => true));
The mergeType is 0 as default, so you can get the same output using:
$merge->mergeDocx('document1.docx', array('document2.docx', 'document3.docx'), 'output.docx', array('importEmbeddedFonts' => true));
If you want to remove existing sections from the second and next documents, add 5 line breaks and set page numbering as restart:
$merge->mergeDocx('document1.docx', array('document2.docx', 'document3.docx'), 'output.docx', array('mergeType' => 1, 'lineBreaks' => 5, 'numbering' => 'restart'));
All options have default values, so you don't need to include them if you don't want to change these default values. On the API documentation page (https://www.phpdocx.com/api-documentation/docxutilities/merge-Word-documents-with-PHP) are explained all available options and how they change the merge output.
In most cases, the best options are the default values:
$merge->mergeDocx('document1.docx', array('document2.docx', 'document3.docx'), 'output.docx', array());
Regards.