I'm trying to generate pdf using laravel-dompdf library. I had downloaded the package through composer.
composer require barryvdh/laravel-dompdf
I had updated my config >> app.php
'providers' => [
....
Barryvdh\DomPDF\ServiceProvider::class,
],
'aliases' => [
....
'PDF' => Barryvdh\DomPDF\Facade::class,
],
I included PDF class in my controller
use PDF;
My controller HomeController.php is
<?php
namespace App\Http\Controllers;
use PDF;
use Illuminate\Http\Request;
class HomeController extends Controller
{
public function index(){
$pdf = PDF::loadView('welcome');
return $pdf->download('invoice.pdf');
}
}
But when I call this method it shows the following error
"fopen(C:\Users\asus\Desktop\Laravel\PDFGenerator\storage\fonts/\b4947bfc07f9f11b363f4d7446cd3e99.ufm): failed to open stream: No such file or directory"
I had also added the following to my bootstrap/app.php
$app->register(\Barryvdh\DomPDF\ServiceProvider::class);
$app->configure('dompdf');
There is no dompdf.php is generated in my config directory. I had tried
php artisan vendor:publish --provider="Barryvdh\DomPDF\ServiceProvider"
But it shows the following error
PHP Fatal error: Uncaught ReflectionException: Class config does not exist in
C:\Users\asus\Desktop\Laravel\PDFGenerator\vendor\laravel\framework\src\Illuminate\Container\Container.php:767 Stack trace: C:\Users\asus\Desktop\Laravel\PDFGenerator\vendor\laravel\framework\src\Illuminate\Container\Container.php(767): ReflectionClass->__construct('config') C:\Users\asus\Desktop\Laravel\PDFGenerator\vendor\laravel\framework\src\Illuminate\Container\Container.php(646): Illuminate\Container\Container->build('config') C:\Users\asus\Desktop\Laravel\PDFGenerator\vendor\laravel\framework\src\Illuminate\Container\Container.php(601): Illuminate\Container\Container->resolve('config', Array) C:\Users\asus\Desktop\Laravel\PDFGenerator\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(740): Illuminate\Container\Container->make('config', Array) C:\Users\asus\Desktop\Laravel\PDFGenerator\vendor\laravel\framework\src\Illuminate\Container\Container.php(1210): Illuminate\Foundation\Application->make('config') C:\U in C:\Users\asus\Desktop\Laravel\PDFGenerator\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 767