simo
simo

Reputation: 311

controling image size with addHtml() from PHPWord 0.16 library

Generating a Word document with addHtml() method from PHPWord 0.16 library, I'm not able to control image size. I get image overflow on my resulting Word document.

I have tried 2 different ways 1) by specifying height / width in style attribute and 2) without ....

1) with attributes :

<div style="text-align:center">
<img alt="" src="http://localhost/tmp/library/userfiles/anzac-brisbane-queensland-112487-o.jpg" style="height:450px; width:600px" />
</div>

<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut justo feugiat, tincidunt urna et, convallis leo. Vestibulum sed quam ullamcorper, tempus odio ac, congue ex. Nulla nec odio ultricies, faucibus enim nec, rhoncus elit. Proin accumsan nunc nibh, vitae ultrices orci egestas vel. </div>

2) with no attribute :

<div style="text-align:center">
<img alt="" src="http://localhost/tmp/library/userfiles/anzac-brisbane-queensland-112487-o.jpg" />
</div>

<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut justo feugiat, tincidunt urna et, convallis leo. Vestibulum sed quam ullamcorper, tempus odio ac, congue ex. Nulla nec odio ultricies, faucibus enim nec, rhoncus elit. Proin accumsan nunc nibh, vitae ultrices orci egestas vel. </div>

I always get overflow ...

Actually, I'd like to :

  1. Be able to parse inline attributes. Don't understand why it does not work right now
  2. Know if it is possible to set a 100 % max width (of the generate document) as default value for all images written by addHtml() method.

I'm not sure I'm facing a bug or misunderstood how it works. I have also seen that QA.

Upvotes: 0

Views: 1344

Answers (1)

ThinhCoder
ThinhCoder

Reputation: 496

Adding with and height attributes works for me Remember don't put px into value of attributes

<img alt="" src="http://localhost/tmp/library/userfiles/anzac-brisbane-queensland-112487-o.jpg" width="600" height="450" />

Hope this help someone still has the same problem

Upvotes: 2

Related Questions