There seems to be 3 methods for inserting an image in a template: replaceTemplateVariableByHTML, addTemplateVariable and addTemplateImage.
Each of these methods inserts an image with dimensions that are different from the original image.
- replaceTemplateVariableByHTML reduces the image size in the final document
- addTemplateVariable and addTemplateImage both increase the image size in the final document
You can see it in the examples :
- when running Template_imageSimple.php, the source image, named logo_phpdocx.gif, is 179 x 118 px, but the image inserted in example_template_imageSimple.docx is 183 x 122 px
- when running Template_image.php, the source image, named image.png, is 223 x 182 px, but the image inserted in example_template_image.docx is 301 x 247 px
I also tried to use replaceTemplateVariableByHTML with many variations of the following code :
$docx->replaceTemplateVariableByHTML('variable', 'block', '', $option_array);
but this method produces an image smaller than the source image.
I have spent a long time trying to figure out a way to work around the issue, but I haven't found anything. Please advise.