Cookbook

Merge anywhere in documents

The MultiMerge class, available for Advanced and Premium licenses, allows to merge two or more DOCX. This merge works in a sequential way: one document after the other, one at a time, from the first to the last one.

phpdocx 9.5 includes the method mergeDocxAt, which enables merging after specific contents in a document, e.g. after a table, paragraph or section. The available options allow to choose any content of the document to be merged.

Practical example

As an example, let's merge two documents and place the contents of the second one after the first paragraph that contains 'Another reference' of the first one.

In-memory DOCX merging (Premium licenses only)

Premium licenses support In-memory DOCX merging, that is, merging that doesn't require creating files.

Related information