[英]dompdf - image output
I'm using the dompdf
library to create PDFs from HTML. 我正在使用dompdf
库从HTML创建PDF。
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. 这样就创建了PDF,但似乎找不到图像。
I've tried to have just <img src="/uploads/images/imag1.jpg" />
, but this also renders the image as a red cross. 我试图只使用<img src="/uploads/images/imag1.jpg" />
,但这也会使图像呈现为红色十字。
I'm using the 0.6.0beta3 version of DomPDF 我正在使用DomPDF的0.6.0beta3版本
Thanks 谢谢
Ok, so it seemed having a path such as the full URL doesn't work. 好的,因此似乎没有完整URL之类的路径。
Neither does <img src="/uploads/images..."
/>` <img src="/uploads/images..."
/>也不
I changed the path to be <img src="uploads/images..." />
which seemed to work 我将路径更改为<img src="uploads/images..." />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.