I am creating a PDF with fpdf I can insert an image such as
$pdf->Image('images/image.jpg',0,20,210,80);
I can insert an image such as
$pdf->Image('http://www.thesearchagents.com/wp-content/uploads/2013/11/Google-Search.jpg',0,20,210,80);
in HTML I can serve an image to my page with
<img src="http://maps.googleapis.com/maps/api/staticmap?center=Berkeley,CA&zoom=14&size=400x400&sensor=false" alt="image" height="200" width="300" />
but if I try
$pdf->Image('http://maps.googleapis.com/maps/api/staticmap?center=Berkeley,CA&zoom=14&size=400x400&sensor=false',0,20,210,80);
I get an error
"FPDF error: Unsupported image type: php"
since it is not the actual image file and is only serving the image I am guessing it does not work with setting the header
header('Content-Type: image/png');
what can I do?
Can I capture the image binary and store it in a variable? to then be passed along?
If so, then my question is: How do capture the image source from a return of a php file and store it in a variable in php?
$bin = file_get_contents('http://your_image_binary_source_url_here'); //fetch binary source
$local_name = "/tmp/".time().'.png';
file_put_contents($local_name, $bin); //create image locally
$pdf->Image($local_name,0,20,210,80); //add image to pdf
unlink($local_name); //delete local image