News

Replacing images in a Word template with PHPdocx

  • Jun 06, 2011

This information is outdated, please, refer to the addTemplateImage method documentation for up to date info.
You may create a template with placeholder images that may be later replaced by other ones with the help of the addTemplateImage method.
In order that PHPDocX recognizes which image should be replace you need to introduce a PHPDocX variables as its associated 'Alt text'.
Sample code:


require_once '../../classes/CreateDocx.inc';

$objDocx = new CreateDocx();

// Call the template
$objDocx->addTemplate('../files/TemplateImage.docx');

// Call the image
$objDocx->addTemplateImage('IMAGE', '../files/img/logo_phpdocx.gif');

$objDocx->createDocx('template_image');