简体   繁体   English

dompdf中的图像

[英]image in dompdf

I used dompdf to generate pdf report.我使用 dompdf 生成 pdf 报告。 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. Dompdf 仅需花费 2 分钟或更多分钟即可生成 2 个带有背景图像的页面。 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.我知道这是一个老问题,但我已经用 DOMPDF 测试了很多东西,我已经阅读了很多关于图像处理缓慢的帖子,我发现在 Dompdf 中使用 png 或 gif 图像会使文件处理非常缓慢。

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.如果您不需要图像的透明度 (alpha),只使用 jpg 图像,您会发现生成 PDF 的速度会快得多。

Check this github issue , which made me test the jpg solution.检查这个github 问题,这让我测试了 jpg 解决方案。

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!!!!如果它对你有用,请记住谢谢我!!!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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