Search code examples
phpfpdfpdftk

FPDF error: Unsupported image type (while using header to define image)


So I have an image string that I insert into a webpage with a header telling the browser it is an image.

So a page would look like this:

<?php
    header('Content-Type: image/png');
    echo $image_data;
?>

http://website.com/randomString.png is used to grab the image (using .htaccess)

When I use the following code, I get the error FPDF error: Unsupported image type

$imagePath = file_get_contents("http://website.com/".$randomString.".png");
$pdf->Image($imagePath,159,185,27);

Does anyone know what I can do to get rid of this error?


Solution

  • Replace Image with MemImage (and copy class from the listing below or copy the functions by itself), otherwise it wants to read image from file.

    http://www.fpdf.org/en/script/script45.php