[英]ErrorException in Cpdf.php line 3855: Undefined index: at barryvdh/laravel-dompdf
我使用的是 laravel 5.2,dompdf 在 localhost 上运行良好,但当移动到 AWS 时,它ErrorException in Cpdf.php line 3855: Undefined index:
,在这一行 (3855) 中有字体变量。
示例代码:
$html = "<h2>Hello</h2>";
PDF::setOptions(['dpi' => 150, 'defaultFont' => 'sans-serif']);
$pdf = PDF::loadHTML($html)->setPaper('a4', 'landscape');
return $pdf->download('pdfview.pdf');
由于 barryvdh/laravel-dompdf 中没有选项,我无法在setOptions
中设置'currentFont' => 'sans-serif'
。 那么我该如何解决 currentFont 问题。
Localhost - Windows - 运行良好。
AWS - Linux - 错误。
通过从storage/fonts
中删除dompdf_font_family_cache.php
文件并让渲染器重新生成缓存来解决错误。
我在 Linux 机器上遇到过这个问题。 显示的错误是
未定义索引:application/third_party/dompdf/lib/fonts\Times-Roman
如果您观察到字体名称“\”之前的目录分隔符在 Linux 环境中不兼容。 此路径分隔符硬编码在../dompdf/lib/fonts文件夹中的dompdf_font_family_cache.php文件中。
在编辑器中打开文件并将“\”替换为“/”。 保存更改。 该代码将开始工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.