Convert HTML to PDF in Laravel (DOMPDF)

DOMPDF Wrapper for Laravel 5, it is an html to pdf converter for laravel 5.

I tried to convert the larvel default auth authorization page to PDF, and the path is http://www.careertag.dev/auth/register . The code used for this purpose is given below. But I get a font. Could you help me solve this problem?

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'); }); 

Mistake

 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 
+7
php laravel laravel-5 dompdf
source share
2 answers

Create a font folder inside the repository and make sure that the repository is writable by the web server by running the follwing command. It worked for me.

 sudo chmod -R 777 storage 

Above (777) can be dangerous , so try accessing the commands below to access it safely.

 sudo find storage -type d -exec chmod 755 {} \; sudo find storage -type f -exec chmod 644 {} \; 
+8
source share

Copy the 'fonts' directory of your theme, paste the location 'project-directory / public / themes / your-theme / path-to-fonts-directory' into the location 'project-directory / storage / fonts-directory' This works for me when I was hanged for a long time.

+1
source share

All Articles