【发布时间】:2018-09-16 23:53:47
【问题描述】:
我正在尝试使用 laravel 和 dompdf lib 生成 pdf 文件。这是我的控制器代码:
public function create(Request $request) {
$pdf = new Dompdf();
$html = Storage::disk('local')->get('public/pdf/template.html');
$pdf->loadHtml($html, 'UTF-8');
$pdf->setPaper('A4', 'portrait');
$pdf->render();
$filename = "Hi!";
return $pdf->stream($filename, ["Attachment" => false]);
}
在template.html 中,我得到了一些 html,在某处我得到了这样的图像:
<img src="img/logo.png" alt="BTS">
但是 dompdf 不能写这个图像:Image not found or type unknown。我的文件系统是:
.pdf
...img
......here is images
...template.html
...*some_fonts_files*
但与此同时,字体加载正常。在 template.html 中渲染图片应该怎么做?
【问题讨论】:
标签: php html laravel render dompdf