replaceVariableByExternalFile

replaceVariableByExternalFile

BASIC / ADVANCED / PREMIUM

Replaces an array of variables by external files.

Description
public void replaceVariableByExternalFile(HashMap<String, String> variables) throws Exception
public void replaceVariableByExternalFile(HashMap<String, String> variables, OptionsReplaceVariableByExternalFile options) throws Exception

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 only compatible with MS Word 2007 and newer.

Parameters

variables

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

options

Option Type Description
firstMatch Boolean If the variable appears more than once within the Word document and firstMatch is set to true, Javadocx 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: