【问题标题】:@font-face Font not loading into mpdf@font-face 字体未加载到 mpdf 中
【发布时间】:2019-01-15 03:33:01
【问题描述】:

我正在为我的网站加载 Google Railway-Light 字体,它工作正常,但它没有加载到我正在生成的 PDF 中。我在我的 CSS 文件中调用它

@font-face {
    font-family: "Raleway-Light";
    src: url("../font/Raleway-Light.ttf");
}

当我生成 PDF 时,我正在调用 CSS 文件。

$pdf = new Pdf(
    [
        'mode' => Pdf::MODE_CORE,
        'format' => Pdf::FORMAT_LETTER,
        'orientation' => Pdf::ORIENT_PORTRAIT,
        'destination' => Pdf::DEST_BROWSER,
        'content' => $content,
        'cssFile' => '/var/www/html/basic/web/css/sites.css',
        'marginRight' => 0,
        'marginLeft' => 0,
        'marginTop' => 0,
        'marginBottom' => 0,
        'marginHeader' => 0,
        'marginFooter' => 0,

        'cssInline' => '',
        'options' => [],
        'methods' => [],
    ]
);

if ($user->role == 0) {
    $pdf->showWaterMark = true;
}
// return the pdf output as per the destination setting
return $pdf->render();

我也将该字体加载到mpdf/ttf 文件夹中。

【问题讨论】:

    标签: fonts yii2 mpdf


    【解决方案1】:

    解决了

    'mode' => Pdf::MODE_CORE, 
    

    需要设置为

    'mode' => '', 
    

    然后我的字体需要包含在FontVariables.php

    【讨论】:

      猜你喜欢
      • 2010-11-22
      • 2013-01-15
      • 1970-01-01
      • 2021-08-16
      • 2019-06-02
      • 1970-01-01
      • 2018-01-11
      • 2016-12-24
      • 2011-10-14
      相关资源
      最近更新 更多