Jump to content

Recommended Posts

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.