简体   繁体   中英

dompdf - image output

I'm using the dompdf library to create PDFs from HTML.

I am having a problem rendering images, as they seem to be appearing as red crosses.

$dompdf = new DOMPDF();

$html = '<div><img src="http://www.domain.com/uploads/images/image1.jpg" /><div>';

$dompdf->load_html($html);
$dompdf->set_paper("A4");
$dompdf->render();
$output = $dompdf->output();
$filename = date('dmYHis') . '-lowres.pdf';

file_put_contents('/uploads/pdfs/low-res/' . $filename, $output);

This creates the PDF, but it doesn't seem to find the image.

I've tried to have just <img src="/uploads/images/imag1.jpg" /> , but this also renders the image as a red cross.

I'm using the 0.6.0beta3 version of DomPDF

Thanks

Ok, so it seemed having a path such as the full URL doesn't work.

Neither does <img src="/uploads/images..." />`

I changed the path to be <img src="uploads/images..." /> which seemed to work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM