【问题标题】:Unable to use font-awesome in Laravel dompdf无法在 Laravel dompdf 中使用 font-awesome
【发布时间】:2021-05-31 02:05:16
【问题描述】:

我们如何在 laravel dompdf 中嵌入 fontawesome 图标?

我通过外部 css 链接添加了 fontawesome

<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/>

并正常使用它,例如&lt;i class="fal fa-lock"&gt;&lt;/i&gt;

这是我得到的错误:

Invalid characters passed for attempted conversion, these have been ignored

【问题讨论】:

    标签: font-awesome dompdf


    【解决方案1】:

    Dompdf 没有正确解析 FontAwesome 样式表,导致它无法正确读取字体系列。 您现在可以通过在包含 FontAwsome 样式表后重新定义 fa 类来解决此问题。

    <!DOCTYPE html>
    <html>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
      <style type="text/css">
      .fa {
        display: inline;
        font-style: normal;
        font-variant: normal;
        font-weight: normal;
        font-size: 14px;
        line-height: 1;
        font-family: FontAwesome;
        font-size: inherit;
        text-rendering: auto;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
      }
      </style>
    </head>
    <body>
      <p><span class="fa fa-envelope"></span> This is text.</p>
    </body>
    </html>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-14
      • 2018-04-07
      • 1970-01-01
      • 2021-04-24
      • 2020-10-07
      • 2018-11-23
      • 2022-08-21
      • 2020-09-20
      相关资源
      最近更新 更多