Laravel 9 show images on PDF from Blade view

23 views Asked by At

I'm using laravel 9 with php 8.2 on docker image.

When I try to set a img on my blade template the img don't show. I have been use a dompdf to create this using workCertification.blade like template from workCertification function.

I have already create the php artisan storage:link

Thanks.

The images are in public/img/*

enter image description here

  • CONTROLLER
 # 2 CREATE TEMPLATE AND SEND INFROMATION.
   $html = view('payroll/workCertification', ['certification' => $certification, ])->render();
   # dompdf OPTIONS
   $options = new Options();
   $options->set('isHtml5ParserEnabled', true);
   $options->set('isRemoteEnabled', true);
   # STAR DOM MODEL
   $dompdf = new Dompdf($options);
   $dompdf->loadHtml($html);
   $dompdf->setPaper('A4', 'portrait');
   $dompdf->render();
   # RETURN PDF 
   return $dompdf->stream();
  • VIEW
 <body>
        <!-- DIFERENT OPTION TO CALL IMG-->
        <div>

   
        <img src="<?php echo URL::asset('img/logo.png') ?>">
        <img src="{{asset('storage/img/logo.png')}}"/>
        <img src="http://localhost:8000/img/logo.png" />
        <img src="{{ url('storage/img/logo.png') }}"/>
        <img src="{{ asset('./img/logo.png') }}" />
        <img src="{{ url('/storage/img/logo.png') }}" />



        </div>
        <br>
        <div style="text-align: center;">
            <h2>CERTIFICACIÓN</h2>
        </div>
</body>
  • RESULT

enter image description here

0

There are 0 answers