Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincej's avatar
Level 15

DOMPDF Error: Non Static Method should not be called statically.

Totaly new to DOMPDF and am not getting very far very fast. The docs. are pretty poor. I have downloaded barry's DomPDF L5 wrapper. and I get this error:

Non-static method Barryvdh\DomPDF\PDF::loadView() should not be called statically, assuming $this from incompatible context

I have tried adding static to the function, but had no effect.

Function

    public function get_pdf(){

        $data = Quotation::where('reference','=','Sam100117-82');
        $pdf = PDF::loadView('create_quote', $data);
        return $pdf->download('quote.pdf');
        

     }

so what is going on ?? Many thanks !

0 likes
6 replies
tykus's avatar

Did you register the Facade properly in the config/app.php?

'PDF' => Barryvdh\DomPDF\Facade::class,
vincej's avatar
Level 15

added this to the aliases in the App / config folder

  'PDF'       => Barryvdh\DomPDF\Facade::class,

Looks right to me.

petrit's avatar

Try this

$data = Quotation::where('reference','=','Sam100117-82');
$view = view('create_quote', compact('data'))->render(); 
$pdf = \PDF::loadHTML($view)->setPaper('a4', 'potrait')->setWarnings(false)->save('myfile.pdf');

tykus's avatar

@vincej what are you importing at the top of your file; the class or the Facade?

vincej's avatar
Level 15

Interesting - the "static" problem has gone away. Thanks ! However, suriously, I was using use Barryvdh\DomPDF;

Ok - progress, now I have a new error:

fopen(/var/www/auburntree/storage/fonts//46f447491707b1fce3177e2aa6be2392.ufm): failed to open stream: No such file or directory

I did previously download GD.

vincej's avatar
Level 15

Ok - I fixed the fonts folder problem. Then I had a xdebug nested maximum =100 problem. Fixed that too. Now I just have to get my data into a reasonable format !

Thanks !

Please or to participate in this conversation.