【问题标题】:Why laravel-dompdf not working di php 7.1?为什么 laravel-dompdf 不工作 di php 7.1?
【发布时间】:2017-02-13 17:16:19
【问题描述】:

我从这里得到:https://github.com/barryvdh/laravel-dompdf

以前,我使用 PHP 7.0.8。我的pdf没有错误

当我使用 PHP 7.1 时,我的 pdf 存在错误

见下文

我的控制器是这样的:

public function listdata(Request $request)
{
    ...
    $pdf = PDF::loadView('test_print.test', ['data' => $data]);
    $pdf->setPaper('legal', 'landscape');
    return $pdf->stream('test_print.test');
}

我的 pdf 视图是这样的:

<h1>This is test</h1>

<table class="tg">
    <tr>
        <th class="tg-3wr7">kolom 1</th>
        <th class="tg-3wr7">kolom 2</th>
        <th class="tg-3wr7">kolom 3</th>
        <th class="tg-3wr7">kolom 4</th>
        <th class="tg-3wr7">kolom 5</th>
    </tr>
    @php ($row = 22)
    @for($i=0;$i<$row;$i++)
    <tr>
        <td class="tg-rv4w">test 1</td>
        <td class="tg-rv4w">test 1</td>
        <td class="tg-rv4w">test 1</td>
        <td class="tg-rv4w">test 1</td>
        <td class="tg-rv4w">test 1</td>
    </tr>
    @endfor
</table>

<br>
<!-- start position signature -->
<div class="signature">
    London,&nbsp;8 January 2017<br>
    Chelsea Player<br><br><br><br>
    Eden Hazard<br>
</div>
<!-- end position signature -->

执行时出现如下错误:

Page.php 第 494 行中的 1/1 ErrorException:非数字值 遇到

为什么 laravel-dompdf 在 php 7.1 中不起作用?

【问题讨论】:

    标签: php laravel pdf laravel-5.3 dompdf


    【解决方案1】:

    PHP 7.1.0 与 Dompdf 0.7.0 及更早版本之间存在已知的不兼容性。请参考issue #1272Dompdf 0.8.0,于 2016 年 2 月 15 日发布,解决了这些问题。

    【讨论】:

    • 我使用 laravel-dompdf。没有dompdf。好像不一样
    • @mosestoh 并没有什么不同,包只是将dompdf 集成到框架中的一种方式。如需进一步说明,请参阅Laravel News
    • @camelCase,好的。意思是我要等到有更新才能下结论?
    • @mosestoh 是的,这是一个选项。如果出于业务原因这不是一个选项,您始终可以将 PHP 回滚到 7.0.8,直到即将发布的 Dompdf 版本完成。
    • @camelCase。好的。谢谢。看来我会再次使用 PHP 7.0.8
    猜你喜欢
    • 2017-10-04
    • 2013-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-15
    • 2016-03-28
    • 2019-01-11
    • 2019-04-05
    相关资源
    最近更新 更多