Laravel HTML到PDF转换(DOMPDF)

Sar*_* TS 7 php dompdf laravel laravel-5

用于Laravel 5的DOMPDF包装器,它是用于laravel 5的html到pdf转换器.

我试图将laravel默认auth注册页面转换为PDF,路径为http://www.careertag.dev/auth/register.用于此目的的代码如下.但是我遇到了字体问题.你能帮我解决这个问题吗?

routes.php文件

Route::post('/screenshot', function(){
    $pdf  =  App::make('dompdf.wrapper');
    //$pdf->loadHTML('<h1>Test</h1>');
    $view =  View::make('auth.register')->render();
    $pdf->loadHTML($view);
    $pdf->stream();
    //return $pdf->stream('invoice');
    return $pdf->download('profile.pdf');
});
Run Code Online (Sandbox Code Playgroud)

错误

ErrorException in font_metrics.cls.php line 343: file_put_contents(C:\xampp\htdocs\careertag\storage\fonts/13350985545a9988387f8a573f409063.ttf): failed to open stream: No such file or directory
Run Code Online (Sandbox Code Playgroud)

Mus*_*zay 9

存储目录中创建fonts文件夹,并通过运行follwing命令确保Web服务器可以写入存储.这对我有用.

sudo chmod -R 777 storage
Run Code Online (Sandbox Code Playgroud)

上面(777)可能是危险的,因此要以安全的方式实现它,请尝试以下命令.

sudo find storage -type d -exec chmod 755 {} \; 
sudo find storage -type f -exec chmod 644 {} \;
Run Code Online (Sandbox Code Playgroud)