【问题标题】:Why getting this error non-numeric value encountered in Laravel?为什么在 Laravel 中遇到此错误非数字值?
【发布时间】:2018-02-18 20:15:15
【问题描述】:

我正在尝试使用 dompdf 在我的 Laravel 5.4 应用程序中下载 pdf 文件。 这是我的控制器代码:

public function htmltopdfview($master_id) {
$ordermaster=DB::table('allorder')->where([['user_id',Auth::user()->id], 
                                          ['id',$master_id]])->first();
$orderdetails=DB::table('allorder_details')->where('master_id',$master_id)->get();
$pdf = PDF::loadView('OrderReport',compact('ordermaster','orderdetails'));
return $pdf->download('invoice.pdf');
return view('OrderReport',compact('ordermaster','orderdetails'));
}

这是我的刀片文件代码:

@foreach($orderdetails as $details)
    <tr>
        <td class="col-md-9"><em>{{$details->product}}</em></td>
        <td class="col-md-1" style="text-align: center">{{$details->product_price}} TK </td>
        <td class="col-md-1" style="text-align: center">${{$details->product_price/80}}  </td>
        <td class="col-md-1 text-center">{{$details->barnd}}</td>
    </tr>
@endforeach

<div>
    <h1 style="text-align:center;">
        Thank you for your order.
        <a href="{{route('pdfdownload',$ordermaster->id)}}">Download PDF</a>
    </h1>
</div>       

这是我的路线:

    Route::get('htmltopdfview/{id}','CheckoutController@htmltopdfview')->name('pdfdownload');

错误截图:

请帮助我。提前致谢

【问题讨论】:

    标签: php laravel php-7.1


    【解决方案1】:

    以防万一我建议确保您的 Dompdf 是最新版本。 Block.php 在最新版本中只有 287 行,而你的错误发生在第 741 行。

    否则您的 HTML 无效并且表格行没有表格。 Dompdf 对任何无效的 HTML 代码都非常敏感。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-28
      • 1970-01-01
      • 2020-11-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多