[英]Dynamic value in <img>'s src attribute in dompdf
I am making a pdf of invoices for multiple companies. 我正在为多家公司制作pdf格式的发票。 Every company has their own logo which they want to be going on the pdf.
每个公司都有自己的徽标,希望在PDF上使用。 I am using dompdf for the sake of pdf generation.
我正在使用dompdf来生成pdf。 Now when hard code the value of src attribute with the relative path of the image it is rendered perfectly fine on the pdf.
现在,当对代码的src属性值和图像的相对路径进行硬编码时,可以在pdf上完美呈现它。 Eg in codeigniter:
例如在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);
Now, as the image's relative path is going to change everytime depending on the client logged in I am trying to give src attribute a dynamic value like such: 现在,由于图像的相对路径每次都会更改,具体取决于登录的客户端,因此我尝试为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);
Where $row->img has the value = images/logo.png for a certain case.(the value is going to change depending on who is logged in). 在特定情况下,$ row-> img的值为= images / logo.png(该值将根据登录的人而改变)。
Using the above code just gives me a blank space on the pdf, not even a broken image neither any error message. 使用上面的代码只会给我pdf上的空白,甚至没有损坏的图像,也没有任何错误消息。 Please help me as its already taken one good day of mine.
请帮助我,因为我已经度过了美好的一天。
Comments, suggestions, answers are highly appreciated Thanks again. 评论,建议,答案受到高度赞赏。再次感谢。
尝试这个:
$html = '<img style = "height: 140px; width: 180px;" src ="'.$row->img.'"/>';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.