DOMPDF Wrapper for Laravel 5, It's a html to pdf converter for laravel 5.
I have tried to convert laravel default auth register page to PDF and the path is http://www.careertag.dev/auth/register. Code used for this purpose is given below. But I am getting font issue. Could you please help me to solve this issue?
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');
});
Error
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
The Dompdf library can be used to convert HTML to PDF using PHP. The Dompdf is a PHP library that helps to convert HTML to PDF document. If your application is built with Laravel, the Dompdf library is the best option to create a PDF file and add HTML content to PDF document.
Dompdf is a query based on the Laravel framework that will help generate a pdf file. It can be integrated in any environment, based on a Laravel framework. Laravel, as we all know is one of the most popular of frameworks and over the years has become the most sought after for e commerce solutions.
Create fonts folder inside storage directory and make sure storage is writable by web server by running follwing command. This worked for me.
sudo chmod -R 777 storage
Above (777) can be dangerous, therefore to achieve it in a secure way, try the below commands.
sudo find storage -type d -exec chmod 755 {} \;
sudo find storage -type f -exec chmod 644 {} \;
Copy the 'fonts' directory of your theme form the location 'project-directory/public/themes/your-theme/path-to-fonts-directory' to the location 'project-directory/storage/fonts-directory' This works for me when I was hanged for long time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With