【发布时间】:2015-07-11 13:28:42
【问题描述】:
我正在为多家公司制作一份 PDF 格式的发票。每家公司都有自己的徽标,他们希望将其放在 pdf 上。为了生成pdf,我使用dompdf。现在,当使用图像的相对路径对 src 属性的值进行硬编码时,它会在 pdf 上完美呈现。例如在codeigniter中:
$this->load->helper(array('dompdf', 'file'));
$html = '<img style = "height: 140px; width: 180px;" src = "images/logo.png" />';
pdf_create($html, 'filename');
$data = pdf_create($html, '', false);
现在,由于图像的相对路径每次都会根据登录的客户端而改变,我试图为 src 属性赋予一个动态值,如下所示:
$this->load->helper(array('dompdf', 'file'));
$html = '<img style = "height: 140px; width: 180px;" src = '; $row->img; $html.=' />';
pdf_create($html, 'filename');
$data = pdf_create($html, '', false);
其中 $row->img 对于特定情况的值为 = images/logo.png。(该值将根据登录者而变化)。
使用上面的代码只会在 pdf 上给我一个空白区域,甚至没有损坏的图像,也没有任何错误消息。请帮助我,因为它已经度过了我美好的一天。
非常感谢您的评论、建议和回答,再次感谢。
【问题讨论】:
标签: php html codeigniter dompdf