addExternalFile

addExternalFile

TRIAL / ADVANCED / PREMIUM

Inserts an external document (DOCX, HTML, RTF or MHT) into the current Word document.

Description
public addExternalFile ( array $options )

This method allows the insertion of an external DOCX, HTML, RTF or MHT document within the current Word document.

When inserting a DOCX document, it is recommended that the page layout of the inserted DOCX coincides with the one of the Word document you are generating with phpdocx, if not you may expect certain formatting problems.

Only compatible with MS Word 2007 or newer.

Parameters

options

An array with the available options.

The possible keys and values are:

key Type Description
src string The path to the document (.docx) that you want to insert within our current Word document.
matchSource bool If true (default value), it tries to preserve as much as possible the styles of the DOCX to be included.
preprocess bool If true it does some preprocessing on the DOCX file to add.
Exceptions

Invalid file extension.

File does not exist.

Code samples

Example #1

The resulting Word document looks like: