I really like html2pdf – it's a great tool but I am have started to experience some problems.
Background:
I am running html2pdf on a fresh ubuntu its 24.04 EC2 instance. The vision of php is 8.3.6.
Until recently I was able to render pdf documents that contained images that were described per the following tag, however I am now receiving a fatal error.
The image code that worked until today is:<img style="margin:10px auto 10px auto;" src="https://my_domain.com/png/my_image.png" width="40">
The fatal error that this causes is:Fatal error: Uncaught Spipu\Html2Pdf\Exception\ImageException: Unable to get the size of the image [https://my_domain.com/png/my_image.png] in /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php:1526 Stack trace: #0 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(5782): Spipu\Html2Pdf\Html2Pdf->_drawImage() #1 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1444): Spipu\Html2Pdf\Html2Pdf->_tag_open_IMG() #2 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1412): Spipu\Html2Pdf\Html2Pdf->_executeAction() #3 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(3136): Spipu\Html2Pdf\Html2Pdf->_makeHTMLcode() #4 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1444): Spipu\Html2Pdf\Html2Pdf->_tag_open_DIV() #5 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1412): Spipu\Html2Pdf\Html2Pdf->_executeAction() #6 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(3136): Spipu\Html2Pdf\Html2Pdf->_makeHTMLcode() #7 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1444): Spipu\Html2Pdf\Html2Pdf->_tag_open_DIV() #8 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1412): Spipu\Html2Pdf\Html2Pdf->_executeAction() #9 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(600): Spipu\Html2Pdf\Html2Pdf->_makeHTMLcode() #10 /var/www/_my_library_file.php(83): Spipu\Html2Pdf\Html2Pdf->writeHTML() #11 /var/www/html/my_testing_file.php(68): save_pdf() #12 {main} thrown in /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php on line 1526
Finally:
I did find an example from the example set that used the following code
<img src="./res/logo.png" alt="Logo Html2Pdf" style="width: 150mm">
I updated my code to use the style method
ie.
<img style="margin:10px auto 10px auto; width:150mm;" src="https://my_domain.com/png/my_image.png">
But the error remains:Fatal error: Uncaught Spipu\Html2Pdf\Exception\ImageException: Unable to get the size of the image [https://my_domain.com/png/my_image.png] in /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php:1526 Stack trace: #0 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(5782): Spipu\Html2Pdf\Html2Pdf->_drawImage() #1 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1444): Spipu\Html2Pdf\Html2Pdf->_tag_open_IMG() #2 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1054): Spipu\Html2Pdf\Html2Pdf->_executeAction() #3 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(760): Spipu\Html2Pdf\Html2Pdf->_setNewPositionForNewLine() #4 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1426): Spipu\Html2Pdf\Html2Pdf->_setNewPage() #5 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1412): Spipu\Html2Pdf\Html2Pdf->_executeAction() #6 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(600): Spipu\Html2Pdf\Html2Pdf->_makeHTMLcode() #7 /var/www/_my_library_file.php(83): Spipu\Html2Pdf\Html2Pdf->writeHTML() #8 /var/www/html/my_testing_file.php(68): service_save_pdf() #9 {main} thrown in /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php on line 1526
I am unsure if this is a problem with the way I am specifying image sizes or if this is a bug.
Please advise – your assistance is appreciated in advance!
Hello,
I really like html2pdf – it's a great tool but I am have started to experience some problems.
Background: I am running html2pdf on a fresh ubuntu its 24.04 EC2 instance. The vision of php is 8.3.6.
Until recently I was able to render pdf documents that contained images that were described per the following tag, however I am now receiving a fatal error.
The image code that worked until today is:
<img style="margin:10px auto 10px auto;" src="https://my_domain.com/png/my_image.png" width="40">
The fatal error that this causes is:
Fatal error: Uncaught Spipu\Html2Pdf\Exception\ImageException: Unable to get the size of the image [https://my_domain.com/png/my_image.png] in /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php:1526 Stack trace: #0 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(5782): Spipu\Html2Pdf\Html2Pdf->_drawImage() #1 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1444): Spipu\Html2Pdf\Html2Pdf->_tag_open_IMG() #2 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1412): Spipu\Html2Pdf\Html2Pdf->_executeAction() #3 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(3136): Spipu\Html2Pdf\Html2Pdf->_makeHTMLcode() #4 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1444): Spipu\Html2Pdf\Html2Pdf->_tag_open_DIV() #5 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1412): Spipu\Html2Pdf\Html2Pdf->_executeAction() #6 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(3136): Spipu\Html2Pdf\Html2Pdf->_makeHTMLcode() #7 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1444): Spipu\Html2Pdf\Html2Pdf->_tag_open_DIV() #8 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1412): Spipu\Html2Pdf\Html2Pdf->_executeAction() #9 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(600): Spipu\Html2Pdf\Html2Pdf->_makeHTMLcode() #10 /var/www/_my_library_file.php(83): Spipu\Html2Pdf\Html2Pdf->writeHTML() #11 /var/www/html/my_testing_file.php(68): save_pdf() #12 {main} thrown in /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php on line 1526
Finally: I did find an example from the example set that used the following code
<img src="./res/logo.png" alt="Logo Html2Pdf" style="width: 150mm">
I updated my code to use the style method ie.
<img style="margin:10px auto 10px auto; width:150mm;" src="https://my_domain.com/png/my_image.png">
But the error remains:
Fatal error: Uncaught Spipu\Html2Pdf\Exception\ImageException: Unable to get the size of the image [https://my_domain.com/png/my_image.png] in /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php:1526 Stack trace: #0 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(5782): Spipu\Html2Pdf\Html2Pdf->_drawImage() #1 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1444): Spipu\Html2Pdf\Html2Pdf->_tag_open_IMG() #2 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1054): Spipu\Html2Pdf\Html2Pdf->_executeAction() #3 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(760): Spipu\Html2Pdf\Html2Pdf->_setNewPositionForNewLine() #4 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1426): Spipu\Html2Pdf\Html2Pdf->_setNewPage() #5 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(1412): Spipu\Html2Pdf\Html2Pdf->_executeAction() #6 /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php(600): Spipu\Html2Pdf\Html2Pdf->_makeHTMLcode() #7 /var/www/_my_library_file.php(83): Spipu\Html2Pdf\Html2Pdf->writeHTML() #8 /var/www/html/my_testing_file.php(68): service_save_pdf() #9 {main} thrown in /var/www/vendor/spipu/html2pdf/src/Html2Pdf.php on line 1526
I am unsure if this is a problem with the way I am specifying image sizes or if this is a bug.
Please advise – your assistance is appreciated in advance!