Forum


Replies: 7   Views: 5977
Image in templage : size change
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by jeremie  · 08-07-2013 - 19:14

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.