replacePlaceholderImage

replacePlaceholderImage

BASIC / ADVANCED / PREMIUM

Replaces a placeholder within a image by a new image.

Description
public void replacePlaceholderImage(String variable, String src) throws Exception
public void replacePlaceholderImage(String variable, String src, OptionsReplacePlaceholderImage options) throws Exception

This method allows to replace a placeholder image that may be fully formatted in Word (border, shadows, effects...) by an image of our choice.

The placeholder image should be tagged using the alternate text option of your Word interface (this may depend on your Word version).

Parameters

variable

The name of the variable that identifies the placeholder image.

src

The path to the image that you want to insert into the Word document.

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.
target String Possible values are: document, header, footer, footnote, endnote or comment.
width Integer The value in cm (float).
height Integer The value in cm (float).
dpi Integer Dots per inch.
mime string Forces a mime (image/jpg, image/jpeg, image/png, image/gif)
Code samples

Example #1

The resulting Word document looks like:

Example #2