News
Merging Word Documents with PHPDocX
- Jul 23, 2012
Warning
This post is outdated. For up date information about merging Word Documents with PHPDocX please refer to Practical guide - Merging.
Since the v2.5.3 the PRO+ package incorporates new utilities that, among other things, allow for the full merging of Word documents.
But what do we mean by "full merging"?
The new mergeDocX method preserves, if so chosen:
The sections of the merged documents including:
Theirs section properties like paper sizes and margins.
Their headers and footers with its associated media.
All styles, including the ones associated with different lists types as well as headings, tables, paragraphs, etcetera.
Embedded images and links.
Charts with all their associated data and options.
Footnotes, endnotes and comments.
One may also choose to preserve the page numbering of the original documents or set the page numbers to run as they would normally do in a Word document.
Although some of this features may seem pretty simple to implement it is not so because of the interrelationships among them and the sophistication of the OOXML standard.
But, of course, the main goal of the mergeDocx method is to encapsulate all that complexity and let the final user to generate a single Word document out of two other ones in just a couple of lines of code:
require_once 'path /classes/DocxUtilities.inc';
$newDocx = new DocxUtilities();
$myOptions = array('mergeType' => 0);
$newDocx->mergeDocx('firstWordDoc.docx', 'secondWordDoc.docx', 'mergedWord.docx', $myOptions);
We hope that you will find of interest this new method that allows to merge sophisticated Word documents so easily.