Laravel PDF:未找到块级父级。不好
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48146417/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel PDF: No block-level parent found. Not good
提问by Md. Sahadat Hossain
My code was just working fine until today. I did not change anything but suddenly my pdf code not working. I am using barryvdh/laravel-dompdf
this package in laravel 5.2
.
直到今天,我的代码都运行良好。我没有改变任何东西,但突然我的 pdf 代码不起作用。我barryvdh/laravel-dompdf
在laravel 5.2
.
I deleted my local project and download from the live server but still, this problem occurs on my local computer. My live project works fine with this code.
我删除了我的本地项目并从实时服务器下载,但仍然在我的本地计算机上出现此问题。我的实时项目使用此代码运行良好。
Here is my code
这是我的代码
$pdf = App::make('dompdf.wrapper');
$pdf->loadView('back_end.pdf_template.make_invoice', ['order_info' =>$order_info, 'order_details' => $order_details]);
return $pdf->stream('inv-' . $order_info->invoice_id . '.pdf');
I also try enable_html5_parser
set to true
. And after this, I am getting another error
回答by Geraldo Novais
No block-level parent found. Not good. This is a parser error
未找到块级父级。不好。这是一个解析器错误
hello friend,
朋友你好,
It can be fixed if you delete spaces between the html, head and body tags, as shown below:
删除html、head、body标签之间的空格即可修复,如下图:
It works:
有用:
<html><head>
...
</head><body>
...
</body></html>
It fails:
它失败:
<html>
<head>
...
</head>
<body>
...
</body>
</html>
I had the same problem, with the same laravel version, when I updated my php from 5.6 to 7.0 version.
当我将 php 从 5.6 更新到 7.0 版本时,我遇到了同样的问题,使用相同的 Laravel 版本。
When I tried to generate the pdf file the message was thrown:
当我尝试生成 pdf 文件时,消息被抛出:
No block-level parent found. Not good.
未找到块级父级。不好。
This solution was found in this github page
这个解决方案是在这个github页面中找到的
https://github.com/dompdf/dompdf/issues/1582#issuecomment-359448550
https://github.com/dompdf/dompdf/issues/1582#issuecomment-359448550
I hope I have been useful
我希望我有用
回答by Victor Priceputu
Had the same issue, for me it was caused by the html
tag not being detected as a block-level parent.
Had to add the following CSS to fix it:
有同样的问题,对我来说,这是由于html
标记未被检测为块级父级引起的。必须添加以下 CSS 来修复它:
html, body {
display: block;
}