dompdf - 当我指定 a4、横向时,它会停止运行
这个有点小众,希望有人能帮忙。
我正在使用 DOMPDF 将 HTML 转换为 PDF 文件 - 使用现有库基础设施的不错的工具包。然而,当我指定“set_paper”方法时,它完全变得疯狂,CPU 不复存在并崩溃。至少可以说很奇怪。当您不指定此项时它会起作用。
代码:-
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->set_paper('a4', 'landscape');
$dompdf->render();
file_put_contents('data.pdf', $dompdf->output());
This is a bit niche, hoping someone can help.
I'm using DOMPDF to convert HTML into PDF files - nice piece of kit using existing library infrastructure. However, when I specify the 'set_paper' method it goes completely mental, sucking CPU out of existence and crashing. Odd, to say the least. It works when you do not specify this.
Code:-
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->set_paper('a4', 'landscape');
$dompdf->render();
file_put_contents('data.pdf', $dompdf->output());
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我对景观有疑问,因为我是
按照
正确的顺序使用的:
I had an issue with the landscape, because i was using
after the
Correct order:
考虑到它在纵向而不是横向时有效,这可能与桌子比一页高有关。如果表格超出一页,则存在一个错误,该错误会导致 DOMPDF 崩溃。要么用另一个元素(如 div)包围内容,要么将表格分成几个表格。
Considering it works when in portrait and not landscape, it probably has to do with a table being taller than one page. There is a bug that causes DOMPDF to crash if a table extends beyond one page. Either surround the content with another element like a div, or break the table apart into several tables.