mb_convert_encoding(): 无法检测 DOMPDF 中的字符编码 Laravel 5.5

mb_convert_encoding(): Unable to detect character encoding in DOMPDF Laravel 5.5

我正在使用 Laravel 5.5 开发应用程序,为了生成 PDF 我正在使用 laravel dompdf 包 这是 Link:https://github.com/barryvdh/laravel-dompdf 为此,我已经在 Github 上创建了问题。

这是我的 Laravel 代码:

public function ViewPDF($id)
    {
        $product = Product::find($id);
        $category = Category::find($product->category_id);
        $product_line = ProductLine::find($product->product_line_id);
         $template = View('product_and_category/PDF_Template', ['data'=>$product]);
        return $this->GeneratePDF($template);

    }
    public function GeneratePDF($html) {
        $pdf = \App::make('dompdf.wrapper');
        $pdf->loadHTML($html);
        return $pdf->stream();
    }

这里是 HTML ,我已经在我的 HTML 中添加了 UTF-8,但仍然有同样的问题,它看起来像是包中的错误。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Title</title>

</head>

<body style="margin:0px;">
<section style="width:100%; margin:0; text-align:center;">
    <div style="background:url({{asset('/images/red-nav-bg.jpg')  }}) repeat-x 0px 68px #702425;">
        <img src="{{ asset('/images/logo.png') }}" width="auto" height="auto" alt="logo" />
    </div>
</section>  <!---**** Section Close ****--->

<div style="width:1100px; margin:30px auto; text-align:center;">
    <img src="assets/images/doorImg2.jpg" width="auto" height="auto" alt="logo" style="padding: 30px 40px; border: 1px solid #cdced1;" />
</div>



<div style="width:1100px; margin:0 auto;">
    <table width="100%" border="1" cellspacing="0" cellpadding="10" style="margin-bottom:30px; font-size:14px; border-color:#cdced1; font-family:sans-serif;">

        <tr>
            <td>Category</td>
            <td>adsfdsaf</td>
        </tr>
        <tr>
            <td>Product Line</td>
            <td>Draft beer systems & refrugeration</td>
        </tr>
        <tr>
            <td>Model #</td>
            <td>D-36-18RL</td>
        </tr>
        <tr>
            <td>Description</td>
            <td>36" L x 18"D stainless steel sink</td>
        </tr>
        <tr>
            <td>Cost</td>
            <td>$</td>
        </tr>
        <tr>
            <td>Number of Faucets</td>
            <td>8</td>
        </tr>
        <tr>
            <td>Material Finishes</td>
            <td>QF_Metal - Mirror - Finished</td>
        </tr>
        <tr>
            <td>Dimension</td>
            <td>15 7/8</td>
        </tr>

    </table>
</div>

<div style="width:100%; margin:0 auto; background-color:#f9f9f9; text-align:center; padding:30px 0px; font-size:13px; color: #ccc; font-family:sans-serif;">
    <p style="margin: 0px;">© 2017 Copyrights</p>
</div>  <!---**** Footer Close ****--->

</body>
</html> 

您收到此错误的原因是因为您包含了美元符号 $,它无法识别美元符号将其删除,您应该没问题。

一些 HTML 标签未在 DOMPDF 中编码,这就是我遇到此错误的原因 在 html 模板中进行一些清理后工作正常