【问题标题】:Laravel dompdf not showing japanese charactersLaravel dompdf不显示日文字符
【发布时间】:2018-06-16 12:53:27
【问题描述】:

我正在为 dompdf 使用 Laravel 5.4 和 barryvdh/laravel-dompdf 插件。我正在使用此代码,

控制器

 $pdf = PDF::loadView('invoice');

查看 (invoice.blade.php)

<!DOCTYPE html>
<html>
<head>
    <title>Invoice</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<div>빨간색</div>
</body>
</html>

使用此代码时,日文文本将无法正确显示。我该如何解决这个问题?

【问题讨论】:

    标签: laravel utf-8 dompdf


    【解决方案1】:

    您可以使用this link 作为答案。它是日文的,但您可以使用谷歌浏览器翻译。

    总结:

    1. http://ipafont.ipa.go.jp/old/ipafont/download.html下载字体文件或使用任何你想要的ttf文件
    2. https://github.com/dompdf/utils下载load_font.php文件到/vendor/dompdf/dompdf/
    3. 执行#php load_font.php ipag $path_to_font_directory/ipag.tt 会生成类似的东西

    找不到粗体文件。
    找不到斜体字体文件。
    找不到粗体字样的人脸文件。
    将 $path_to_font_directory/ipag.ttf 复制到 $laravel_install_directory /vendor/dompdf/dompdf/lib/fonts/ipag.ttf...
    为 $laravel_install_directory /vendor/dompdf/dompdf/lib/fonts/ipag 生成 Adob​​e Font Metrics...

    1. 将字体文件复制到存储#cp lib/fonts/* /storage/fonts/
    2. 在css中引用你的字体

    body {
    font-family: ipag;
    }

    【讨论】:

      猜你喜欢
      • 2016-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-07
      • 2015-09-17
      • 1970-01-01
      • 2020-02-12
      • 2021-03-24
      相关资源
      最近更新 更多