简体   繁体   中英

image in dompdf

I used dompdf to generate pdf report. My report requires background images on every page. it works, but not that well. Dompdf consumes 2 or more minutes just to generate 2 pages with background image. Is there a way to optimize this?

I know this is an old question but I have tested many things with DOMPDF and I have read so many posts about slow processing of images and I have found out that using png or gif images in Dompdf makes the processing of the file very slow.

If you don't need to have transparency (alpha) on images, use only jpg images and you'll see that generation of PDF will be much faster.

Check this github issue , which made me test the jpg solution.

Insert some monitoring/profiling code and output results into the generated file to see what part is taking the longest. Shouldn't be a problem with images I bet it's a loop gone wild at some point.

Here is the solution you need! Don't use external url

DON'T

url('storage/my-pic.jpg');

DO LIKE THIS

Use public_path('storage/my-pic.jpg');

Remember THANK ME IF IT WORKS FOR YOU!!!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM