PDF 中的汉字 (laravel-dompdf)

Chinese characters on PDF (laravel-dompdf)

我想在我的 PDF 中显示一些中文字符;但事实证明它比我想象的要复杂得多。

我正在使用供应商 laravel-dompdf,我尝试了很多字体,例如:Fyrefly SungSimHeiSimSunUnifont 作为关注:

@font-face {
    font-family: SimHei;
    src: url('{{base_path()."/public/assets/fonts/fireflysung.ttf"}}') format('truetype');
}
.chinese{
    font: Arial 14px;
    line-height: 16px;
    font-family:  Firefly Sung;
}

以及 CDN:

@font-face {
    font-family: 'Firefly Sung';
    font-style: normal;
    font-weight: 400;
    src: url(http://foo.bar/fireflysung.ttf) format('truetype');
}
.chinese{
    font: Arial 14px;
    line-height: 16px;
    font-family:  Firefly Sung;
}

示例:

<span class="chinese">不含弹性织物</span>

但我无法让它工作,因为我的 PDF 显示其他汉字:

ゴム部を除く

我已经解决了我的问题:

我在调用stream()之前删除了output()方法的调用:

// $pdf->output();
return $pdf->stream($myPDFName);

现在可以正常工作了。