Search code examples
phplaraveldompdf

Laravel download view as pdf with images


I am using barryvdh/laravel-dompdf package to download view as a pdf. In the page I have put some images with internal links. Internal links are protected with auth and some other middleware. When I see the view all images are there, but after downloading the pdf, images are not being loaded (Shows message: Image not found or type unknown) due to auth middleware.

What can be the alternative ways to download pdf with images.

I can't remove middleware from the image url.


Solution

  • This is what I did, I fetched the images in the controller itself and then converted the images as base64 image. And then passed to the view. Now everything is working fine.