spipu / html2pdf

OFFICIAL PROJECT | HTML to PDF converter written in PHP
http://html2pdf.fr/en/default
Open Software License 3.0
1.68k stars 751 forks source link

Image incorrect size in PDF output #807

Closed tree28 closed 2 months ago

tree28 commented 2 months ago

Hello, Firstly, thank you for creating this great tool - html2pdf is wonderful!

Background: I am sending a document that contains text and a PNG image to output as a pdf. The text and image render correctly in HTML.

Problem: When opening the pdf the text renders correctly but the PNG image does not. The image width and height size attributes seem to have no effect, as a result the PNG image fills the entire page width.

Here is the html image tag used: <img src="/var/www/html/test_image.png" width="40px">

I have looked for documentation [ here ] but could not find instructions for image sizing.

Your assistance is greatly appreciated in advance.

tree28 commented 2 months ago

All, Anyone who has this problem the solution is to use non-standard HTML. ie. <img src="/var/www/html/test_image.png" width=40>

This is confusing and not ideal. I have decided to leave this case open in the hope that an improvement will be made in the future to enable a standard dimension method or css style methods.

spipu commented 2 months ago

Hi, it is the html spec : https://www.w3schools.com/tags/att_img_width.asp

width="40" : valid width="40px": not valid