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

vannian's avatar

unable to view image with DOMPDF

I am still working in development not in a deployed environment and using mac. I have the following code:

$pdf = PDF::setOptions(['isHtml5ParserEnabled' => true, 
                                'isRemoteEnabled' => true, 
                                'defaultFont' => 'sans-serif',
                                'chroot'  => public_path('storage/e-signatures')])
                    ->loadView('pdf.contract_pdf', compact('contract'));
        $pdf->setBasePath($_SERVER['DOCUMENT_ROOT']);
        
        return $pdf->download('disney.pdf');

it contiues to have error with: Undefined type 'PDF'.intelephense(1009) but able to generate the pdf.

however for the image I tried both code:

    <img src="{{ base_path()}}/logo.png" style="width: 200px; height: 200px">
    <img src="{{ public_path('logo.png') }}" style="width: 200px; height: 200px">

both of them does not work. In generated pdf I have: Image not found or type unknown

0 likes
3 replies
Sinnbeck's avatar

How about an url

<img src="{{ asset('logo.png') }}" style="width: 200px; height: 200px"> 
vannian's avatar

I also tried to put a url from web, same it does not work.

vannian's avatar

after uploading to real server it worked with external url

Please or to participate in this conversation.