Hello,
Sorry, but we are not sure if we understand your issue correctly.
Do you mean if you use the following code it runs correctly?:
$image_options = array(
'height' => 2,
'width' => 2,
'target' => 'header',
);
$docx->replacePlaceholderImage('QRCODE', 'docs/image1.png' , $image_options);
$docx->createDocx('docs/'.$filename);
But if you use the following code it doesn't work?:
$qrcode_id = 'image1';
$image_options = array(
'height' => 2,
'width' => 2,
'target' => 'header',
);
$docx->replacePlaceholderImage('QRCODE', 'docs/'.$qrcode_id.'.png' , $image_options);
$docx->createDocx('docs/'.$filename);
The only difference is that a variable is used to set the image path.
What is the value of $qrcode_id in your code?:
$qrcode_id = $_POST['qrcode_id'];
a string with the file path? an URL? a stream?
We have done some tests and everything is working correctly. For example, if we change the examples/Templates/replacePlaceholderImage/sample_1.php script included in the package to use a variable to set the image path and we run the following code:
$docx = new CreateDocxFromTemplate('../../files/placeholderImage.docx');
$imagePath = '../../img/';
$image_1 = array(
'height' => 3,
'width' => 3,
'target' => 'header',
);
$docx->replacePlaceholderImage('HEADERIMG', $imagePath . 'logo_header.jpg', $image_1);
$docx->replacePlaceholderImage('LOGO', $imagePath . 'imageP3.png');
$docx->createDocx('example_replacePlaceholderImage_1');
the DOCX is generated correctly.
For further support please send to contact[at]phpdocx.com the most simple script that illustrates your code using phpdocx standalone (without external resources such as frameworks, databases...), the image you are adding (you can also send the DOCX template you are using) and the DOCX output you get. We'll check them.
Regards.