replaceVariableByExternalFile

replaceVariableByExternalFile

BASIC / ADVANCED / PREMIUM

Replaces an array of variables by external files.

Description
public replaceVariableByExternalFile (array $variables[, array $options])

With the help of this method one may replace a single placeholder variable by a whole external document.

This method accepts the following document formats: DOCX, RTF, HTML and MHT.

This method is not compatible with the phpdocx PDF conversion plugin.

Parameters

variables

This is an array with the placeholder variables as keys and the path to the corresponding external document as value.

options

The possible keys and values of this array are:

Key Type Description
firstMatch boolean If the variable appears more than once within the Word document and firstMatch is set to true, phpdocx will only replace the first ocurrence of the variable within the Word document.
matchSource boolean If true (default value) tries to preserve as much as possible the formatting of the inserted document.
Code samples

Example #1

The resulting Word document looks like: