DWilliams Posted May 24, 2010 Share Posted May 24, 2010 I've tried posting this on the DOMPDF newsgroup but it's not very populated and I haven't had a response yet. I'm hoping somebody here has worked with DOMPDF before. I'm using DOMPDF to make PDF reports. Everything works great except images. Here is the relevant portion of my code: $reportHTML = getReportHTML(); // Check to see if a PDF was requested if($_GET['target'] == 'pdf') { // User is requesting a PDF download, create the PDF structure and send it to them $reportHTML = '<html><body style="margin: 2em;"> <img src="/var/www/images/logoheader.gif" style="width:200px;height:200px"> <table width="100%" style="background-color:#000; color:#FFF; font-weight:bolder; font-size:150%; text-align:center"><tr><td>' . $reportConfig['title'] . '</td></tr></table>' . $reportHTML . '</body></html>'; ob_clean(); require_once('lib/dompdf/dompdf_config.inc.php'); $pdf = new DOMPDF(); $pdf->load_html($reportHTML); $pdf->render(); $pdf->stream(strtolower(str_replace(' ', '_', $reportConfig['title'])) . '_' . date('n/j/y-G:i') . '.pdf'); } This works absolutely fine if I remove the <img> element in $reportHTML. As soon as I add it back in, I get a blank white page instead of a PDF when I run the report. That image is indeed at that path and is indeed a working image. I've tried it with other images, nothing works. I've tried both absolute and relative paths. I've googled this problem and haven't found any solutions. I found one suggestion saying to make sure that DOMPDF's temp directory is writeable by the webserver, and I verified that the temp directory is set to /tmp and www-data can write to it. How can I get images on my reports? It looks pretty bad without our logo for obvious reasons. Quote Link to comment https://forums.phpfreaks.com/topic/202740-trying-to-use-dompdf-for-my-reports-doesnt-work-with-images/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.