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

Eloïse's avatar

DomPdf SVG image shows Image or type not found

Hello,

I'm using barryvdh/laravel-dompdf 2.2 and this code in a controller in order to generate a simple barcode It works perfectly locally with Mamp but when I try on the remote server I got a cross in place of the barcode in svg format with the message image or type not found. I tried to display the view in order to test if it was the svg the problem but it's ok... I checked the php extensions too, so I don't have any ideas more...

Thanks for your help.

$html = '<div style="width: 200px;">
                    <div style="text-align: center" class="flex place-content-center text-center mt-3">
                        <a class="block" style="text-decoration:none;color: black" target="_blank" href="' . route('print-barcode', ['vehicle' => $vehicle]) . '">
                            <div class="text-center mb-1">
                                ' . mb_strtoupper($vehicle->owner->name) . '
                            </div>
                            <div class="bg-white">
                                <img class="object-cover w-96" src="data:image/svg+xml;base64,' . base64_encode($vehicle->barcode) . '"/>
                            </div>
                            <div>
                                ' . $vehicle->police_number . '
                            </div>
                        </a>
                    </div>
                 </div>';



        $pdf = App::make('dompdf.wrapper');
        //$pdf = \Pdf::loadView('print-barcode',\compact('vehicle'));

        \Barryvdh\DomPDF\Facade\Pdf::setOptions(
            [
                'isHtml5ParserEnabled' =>true,
                'isRemoteEnabled' => true,
            ]
        );
        $pdf->loadHTML($html);

        return $pdf->stream();
0 likes
1 reply
Eloïse's avatar

Humm it' seems to be related with that :

cat storage/logs/laravel.log

[2024-06-10 13:12:21] local.ERROR: Unable to create temporary image in /tmp
 data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI

Please or to participate in this conversation.