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

Nix1128's avatar

DOMPDF "Image not found or type unknown"

Hi guys

I have to display image on PDF File via DOMPDF.

All I get so far is "Image not found or type unknown"

Based on docs and research i have used those 3 methods in my Controller. None of those gives the correct result

//  1        $pdf = PDF::loadView('frontview.PDF.PDFReport',array('enable_remote' => false,'name' => $name,'votes'=> $votes,'post_id' => $post_id))->setPaper('a4', 'portrait')->setOptions([
//                'tempDir' => public_path(),
//                'chroot'  => '/public/storage/e-signatures/',
//            ]);;



//   2         return PDF::setOptions(['isHtml5ParserEnabled' => true, 'isRemoteEnabled' => true])
//            ->loadView('frontview.PDF.PDFReport',array('name' => $name,'votes'=> $votes,'post_id' => $post_id))->setPaper('a4', 'portrait')
//            ->stream('VoteReport.pdf');


//



        //3

$pdf = PDF::loadView('frontview.PDF.PDFReport',array('name' => $name,'votes'=> $votes,'post_id' => $post_id))->setPaper('a4', 'portrait');
        return $pdf->stream((Carbon::now()->format('Ymd').'VoteReport.pdf'));
    }
}

I have tried all these lines in my view.blade.

                 @php $picture = asset('storage/e-signatures'.$user->docusign); @endphp
                    {{--<img src="{{ $user->docusign }}">--}}
                    {{--<img src="storage/{{ $user->docusign }}" width="70">--}}
                    <img src="{{ base_path() }}/storage/e-signatures.{{$user->docusign}}"  class="pic_preview" width="50px" height="50px">
                    {{--<img src="{{ $picture }}" class="pic_preview" width="50px" height="50px">--}}
                    {{--<img src="{{asset('storage/e-signatures'.$user->docusign)}}--}}
                    {{--<img src="{{public_path('storage/e-signatures/'.$votes->docusign)}} ">--}}
                    {{--C:\xampp\Laravel\blog\public\storage/e-signatures/5f71a5e38e91f.png--}}
                    {{--C:\xampp\Laravel\blog\public/storage/app/public/e-signatures/5f6a05344a52d.png
                    {{--http://localhost/storage/app/public/pic/user_pic/82ac9404bdb74d0ad980a30faadeab22cd41b38d.jpg
                    /storage/pic/user_pic/--}}

I am saving the image like this:

     $folderPath = public_path('storage/e-signatures/');
        $image_parts = explode(";base64,", $request->signed);
        $image_type_aux = explode("image/", $image_parts[0]);
        $image_type = $image_type_aux[1];
        $image_base64 = base64_decode($image_parts[1]);
        $signature = uniqid() . '.' . $image_type;
        $file = $folderPath . $signature;
        file_put_contents($file, $image_base64);
        $signed->docusign = $signature;
        $signed->save();
        return back()->with('message', '');

{{$user->docusign}} gets me the the exact match of the field that i want.

I can also access it relative path and absolute path.

But i cant NEVER display it on PDF

Please HELP 3-days on that already.

0 likes
11 replies
isaqqer's avatar

try this to know your path

Route::get('/url', function (){ return asset('public/storage/e-signatures'); });

and then use it

Snapey's avatar

don't put localhost in your code or you will never be able to publish your application.

this one file:///C:/xampp/Laravel/blog/public/storage/e-signatures/ opens a folder with already saved images

What is the URL of one of the pages of your application? Do you see 'public' in the URL?

Assuming NO, then you should use

img src="{{ asset('/storage/e-signatures/' . $user->docusign) }}"

Assuming that the docusign field only contains the filename and no part of the file path

1 like
Nix1128's avatar

Ok i fixed it.

The issue was as follows:

I am using DOMPDF version 0.8.6. This version has changes that are not well documented and is looking more strictly for the local file path

In short, to be able to get and slap an image on your pdf file you need to explicitly state the folder where your images are.

Two ways to do it:

  1. Is called Options.php file which is located in dompdf/src/ - on line 294 where you want to change

$this->setChroot(realpath(__DIR__ . "/../")); like

$this->setChroot(realpath(__DIR__ . "/path/to/folder"));

2 To reference it on your controller with 'chroot' key and value to the folder path where images are like this:

    ->setOptions([
        'enable_remote' => true,
        'chroot'  => public_path('storage/e-signatures'),
    ]);
        return $pdf->stream((Carbon::now()->format('Ymd').'VoteReport.pdf'));
}
3 likes
Snapey's avatar

NEVER change the code of a vendor package

1 like
ashaduzzaman5698's avatar

Not working for public folder, and its show the image in browser but not showing in the pdf

Please or to participate in this conversation.