Reputation: 18103
FPDF error: Image file has no extension and no type was specified:
Is the error I receive when I try to have this:
<img src="https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=LG-80294959&choe=UTF-8">
In my html, that FPDF will html2pdf convert.
So how can i do this? I really need this QR chart inside this pdf.
Upvotes: 2
Views: 3024
Reputation: 158
After spending hours on this exact problem I finally figured it out. First, as others has suggested, I did NOT need to add a &.png at the end of my url. The key turned out to be the spaces in the labels.
$chart_url = str_replace(" ","%20",$chart_url);
echo '< img src="'.$chart_url.'"/>'; (remove the space between < img)
The above worked perfectly.
Here is the full code as requested. I removed the header and footer...
<?
import('html2pdf.class');
ob_start();
?>
<style type="text/css">
</style>
<page backtop="120px" backbottom="105px" backleft="10mm" backright="10mm" style="font-size: 10pt">
<bookmark title="Test" level="0" ></bookmark>
<img src="https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=VS-26258807&choe=UTF-8" />
</page>
<?
$html = ob_get_clean();
// init HTML2PDF
$html2pdf = new HTML2PDF('P', 'A4', 'fr', true, 'UTF-8', array(0, 0, 0, 0));
// display the full page
$html2pdf->pdf->SetDisplayMode('fullpage');
// convert
$html2pdf->writeHTML($html);
// send the PDF
return $html2pdf->Output('shop_preview.pdf','true');
return $file;
Then I simply echo'd the returned '$file'.
Here is the fpdf class I use: http://html2pdf.fr/en/download
Upvotes: 4