user934167
user934167

Reputation:

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?

Upvotes: 2

Views: 4176

Answers (3)

MUHINDO
MUHINDO

Reputation: 1241

Don't use external url

DON'T

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

DO LIKE THIS

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

Upvotes: 1

otinanai
otinanai

Reputation: 4023

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.

Upvotes: 4

Vlad
Vlad

Reputation: 119

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.

Upvotes: 1

Related Questions