replaceImage

replaceImage

PREMIUM TRIAL / ADVANCED

Bulk processing. Replaces a placeholder within an image by a new image.

Description
public replaceImage (array $variables, array $options)
Parameters

variables

This is an array that each position sets a DOCX document. In this array, another array set the new contents.

options

The possible keys and values of this array are:

Key Type Description
dpi int Dots per inch. This parameter is only taken into account if width or height are set to auto.
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 occurrence of the variable within the Word document.
height mixed The value in cm (float) or 'auto' (use image size).
mime string Forces a mime (image/jpg, image/jpeg, image/png, image/gif)
streamMode bool If true, uses src as stream. PHP 5.4 or greater needed to autodetect the mime type; otherwise set it using mime option. Default is false.
target array Possible values are: document, header, footer (all as default).
width mixed The value in cm (float) or 'auto' (use image size).
Exceptions

Image does not exist.

Image format not supported.

getimagesizefromstring not available using streamMode and mime/height/width values are not set.

Code samples

Example #1