addExternalFile

addExternalFile

BASIC / 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 we are generating with phpdocx, if not you may expect certain formatting problems.

This method is not compatible with the conversion plugin: the inserted docx will not render at all in the resulting PDF, DOC, RTF, ODT or HTML document.

Parameters

options

An array with the available options.

The possible keys and values are (required options are shown with red background):

key Type Description
src string The path to the document (.docx) that we 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 boolean If true it does some preprocessing on the docx file to add.

Beware that the docx to insert gets modified, so please make a safeguard copy first.

Return values

Void.

Code samples

Example #1

The resulting Word document looks like: