1
votes

I have Laravel 6 project and when I use Barryvdh\DomPDF to load the pdf into my public folder I get the message error below

The "Symfony\Component\Debug\Exception\FatalThrowableError" class is deprecated since Symfony 4.4. 16384

This is my Controller function

<?php

namespace App\Http\Controllers\MyController;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use PDF;

class MyController extends Controller
{

  function load_pdf(Request $req){

    $data = [ 'Message' => 'MY PDF'];
    PDF::loadView('pdf', $data)->save(public_path())->stream('mypdf.pdf');
    return "It's Okey";

   }
}

'pdf' it's a view in the views folder and i already add this to my app file in config folder

'providers' => [
    ....
    Barryvdh\DomPDF\ServiceProvider::class,
],

'aliases' => [
    ....
    'PDF' => Barryvdh\DomPDF\Facade::class,
]

Any solution ??

2
There's a bug open on Barryvdh\DomPDF's GitHub page, but it hasn't been addressed yet. So it has nothing to do with your code, and everything to do with the package and it's dependencies. - aynber
so there is no solution for this :/ - DevTeam
Not that I know of. It's a discrepancy between versions of Symfony. You can try upgrading all packages and see if that helps. - aynber

2 Answers

0
votes

For information, you should put your code in a try/catch bloc to handle the exception and know more about the error.

0
votes

I had an error as I know it in a pdf and it is resolved with the tags <pre> </pre> since this is rendering the html in the pdf, which happens when you send html from the db, for the pdf format . I solve it this way, I hope you do too.

<pre>{!!$response->data!!}</pre>