我正在尝试在 Laravel 创建的 PDF 中指定字体

Uma*_*riq 3 php pdf fonts laravel

我正在使用niklasravnsborg/laravel-pdf在 Laravel 中创建 PDF 文件。我想使用 Arial 字体,但该字体不起作用。

$pdf = PDF::loadView('blade', $data, [], [
    'format' => 'A4-L',
    'orientation' => 'L'
]);
Run Code Online (Sandbox Code Playgroud)

小智 6

我陷入了同样的问题。下面是它的具体解决方案

$pdf = PDF::loadView('blade',$data, [], [
                     format' => 'A4-L',
                     'orientation' => 'L',
                     'mode' => 'c'
                    ]);
Run Code Online (Sandbox Code Playgroud)

在刀片文件中,您应该需要在顶部添加

<style type="text/css">

    body {
        font-family: Arial, Helvetica, sans-serif;
    }
</style>
Run Code Online (Sandbox Code Playgroud)