dompdf 和 img 标签,图像不会显示

2021-12-29 00:00:00 pdf php dompdf drupal

这是调用 $dompdf->render() 和 $dompdf->output() 之前的 HTML:

Here is the HTML just before $dompdf->render() and $dompdf->output() are called:

<img src="http://www.example.com/images/Logo.png" />

所有其他发票在浏览器中查看、打印或以 HTML 格式通过电子邮件发送时都能正常显示图像.当我在应用程序中单击生成 PDF"时,它会以 PDF 格式呈现发票,但缺少徽标.我已经添加了一个调试行,通过电子邮件将它发送到 render() 的原始 HTML 发送给我,我觉得它很好.

All other invoices display the image fine when viewing in the browser, or printing it, or emailing it as HTML. When I click 'Generate PDF' inside of our application, it renders the invoice in PDF, except the logo is missing. I have put a debugging line in to email me the raw HTML it sends to the render(), and it looks fine to me.

有谁知道为什么 dompdf 不显示此图像?

Does anyone have any idea why dompdf won't display this image?

推荐答案

一个想法:如果您为图像提供完整的 URI,它被视为外部图像,因此定义的 costant DOMPDF_ENABLE_REMOTE 必须设置为是真的.

An idea: if you are providing full URI to the image it is treated as external, so defined costant DOMPDF_ENABLE_REMOTE must be set to true.

相关文章