Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Unable to get imagesize" instead of "image not here" #526

Open
Anton-Korduan opened this issue Dec 16, 2019 · 8 comments
Open

"Unable to get imagesize" instead of "image not here" #526

Anton-Korduan opened this issue Dec 16, 2019 · 8 comments

Comments

@Anton-Korduan
Copy link

@Anton-Korduan Anton-Korduan commented Dec 16, 2019

Hi there!

A few weeks ago, I worked with an old version (from around 2016?) of HTML2PDF and in this version if a image (Source of an IMG-Tag) was not there, I got a readable error-message like "the image xy could not be loaded".

But now, with the newest Version of HTML2PDF, I get a "HTTP Error 500" and after analyzing I realized, that its really only the not existing image, which is the reason.

The HTTP500 occurs only because I get the content via PHP "ob_get".

The real Error behind of this is: "Fatal error: Uncaught Spipu\Html2Pdf\Exception\ImageException: Unable to get the size of the image".

Here is a realtime-test:

Working:
https://www.e-mentor.de/system/_errortest.php

Not working (just IMG-filename changed):
https://www.e-mentor.de/system/_errortest2.php

What can I do or what is the next step, to find out, what's going wrong here?

Thanx a lot,
Anton

@Anton-Korduan

This comment has been minimized.

Copy link
Author

@Anton-Korduan Anton-Korduan commented Jan 2, 2020

Happy new year - has anybody an idea or can help me with my problem?

@Mr-TOA

This comment has been minimized.

Copy link

@Mr-TOA Mr-TOA commented Jan 3, 2020

Hi Anton happy new year
always attach the codes to your descriptions.
what version do you use ? is it the latest version ?

@Anton-Korduan

This comment has been minimized.

Copy link
Author

@Anton-Korduan Anton-Korduan commented Jan 3, 2020

Thanx, @Mr-TOA !

Yes, I am using the latest version [5.2.1].

And yes, sorry - of course you need the code - here we go:

https://www.e-mentor.de/system/_errortest.php:
`

header('Content-Type: text/html; charset=utf-8');
error_reporting(E_ALL | E_STRICT);
ini_set('arg_separator.output','&');
setlocale(LC_TIME, "de_DE.utf8");

require_once __DIR__.'/html2pdf_neu/vendor/autoload.php';

use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;                

ob_start();

echo 'images/icon_image.png: <img src="images/icon_image.png" />';

$content = ob_get_clean();

try
{


    $html2pdf = new HTML2PDF('P', 'A4', 'de', true, 'UTF-8', array(25, 25, 25, 15));
    $html2pdf->pdf->SetDisplayMode('fullpage');
    $html2pdf->writeHTML($content, isset($_GET['vuehtml']));
    $html2pdf->Output('_pdf_test.pdf');

}
catch(HTML2PDF_exception $e) {
    echo "Konnte PDF nicht erstellen: ".$e;
}

`

https://www.e-mentor.de/system/_errortest2.php:
`

header('Content-Type: text/html; charset=utf-8');
error_reporting(E_ALL | E_STRICT);
ini_set('arg_separator.output','&amp;');
setlocale(LC_TIME, "de_DE.utf8");

require_once __DIR__.'/html2pdf_neu/vendor/autoload.php';

use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;                

ob_start();

echo 'images/icon_image_NOT_HERE.png: <img src="images/icon_image_NOT_HERE.png" />';

$content = ob_get_clean();

try
{


    $html2pdf = new HTML2PDF('P', 'A4', 'de', true, 'UTF-8', array(25, 25, 25, 15));
    $html2pdf->pdf->SetDisplayMode('fullpage');
    $html2pdf->writeHTML($content, isset($_GET['vuehtml']));
    $html2pdf->Output('_pdf_test.pdf');

}
catch(HTML2PDF_exception $e) {
    echo "Konnte PDF nicht erstellen: ".$e;
}

`

@Mr-TOA

This comment has been minimized.

Copy link

@Mr-TOA Mr-TOA commented Jan 3, 2020

@Anton-Korduan your code is working fine for me
did you get html2pdf through composer or somewhere else ?
i just checked the version that im using it is 6.2.25

@Anton-Korduan

This comment has been minimized.

Copy link
Author

@Anton-Korduan Anton-Korduan commented Jan 9, 2020

@Anton-Korduan your code is working fine for me
did you get html2pdf through composer or somewhere else ?
i just checked the version that im using it is 6.2.25

@Mr-TOA Yes, I installed it through composer.

And the latest versions seemst to be 5.2.1, look here: https://github.com/spipu/html2pdf/blob/master/CHANGELOG.md

@oleteacher

This comment has been minimized.

Copy link

@oleteacher oleteacher commented Jan 13, 2020

@Anton-Korduan - I think what @Mr-TOA is saying:

If you install locally with composer, there are two versions (or at least on my windows machine). The "technickcom" folder holds newest 6.2.25.

Using it solved a lot of problems for me, including the imagesize issue experiencing with older Spipu version. Had to do a little reconfigure, but my app seems much smoother now:)

@Anton-Korduan

This comment has been minimized.

Copy link
Author

@Anton-Korduan Anton-Korduan commented Jan 17, 2020

@oleteacher

Hi Susan!

Do you speak about TCPDF?
I thought Mr.Toa talked about html2pdf, which uses tcpdf within the technickkom-folder.

Or am I wrong here and there are different versions of html2pdf?

PS: I have also the tcpdf-folder with the tcpdf-version 6.2.25 in it - therefore "yes, I use the actual version".

@oleteacher

This comment has been minimized.

Copy link

@oleteacher oleteacher commented Jan 17, 2020

@Anton-Korduan My bad, you are correct.

Guess I used TCPDF in technickkom folder without Spipu. Only way I got around the imagesize issue. Lost ability to use the example templates, but least can use TCPDF:)

Take a look at example 61 in technickkom/example folder and load external file. Using that method was able to get my project working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.