使用dompdf在pdf图像中出错 [英] error in pdf image using dompdf

查看:1120
本文介绍了使用dompdf在pdf图像中出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在生成的PDF的每个页面中显示徽标。虽然它在本地系统中工作正常但它会在服务器中引发异常:

I have to display a logo in every page of a generated PDF. Though it works fine in the local system, it throws following exception in the server:

Fatal error: Uncaught exception 'PDFlibException' with message 'Handle parameter or option of type 'image' has bad value 0' in /var/www/dev/subdomains/rfqms/httpdocs/sprintnineteen/system/plugins/dompdf/include/pdflib_adapter.cls.php:664 Stack trace: #0 /var/www/dev/subdomains/rfqms/httpdocs/sprintnineteen/system/plugins/dompdf/include/pdflib_adapter.cls.php(664): PDFlib->fit_image(0, 30, 746, 'boxsize={86 43}...') #1 /var/www/dev/subdomains/rfqms/httpdocs/sprintnineteen/system/plugins/dompdf/include/php_evaluator.cls.php(66) : eval()'d code(16): PDFLib_Adapter->image('http://rfqms.de...', 'jpg', 30, 3, 86.4, 43.2) #2 /var/www/dev/subdomains/rfqms/httpdocs/sprintnineteen/system/plugins/dompdf/include/php_evaluator.cls.php(66): eval() #3 /var/www/dev/subdomains/rfqms/httpdocs/sprintnineteen/system/plugins/dompdf/include/php_evaluator.cls.php(70): PHP_Evaluator->evaluate('??//$base_img_u...') #4 /var/www/dev/subdomains/rfqms/httpdocs/sprintnineteen/system/plugins/dompdf/include/renderer.cls.php(180): PHP_Evaluator->render(O in /var/www/dev/subdomains/rfqms/httpdocs/sprintnineteen/system/plugins/dompdf/include/pdflib_adapter.cls.php on line 664

经过一些分析后我发现在本地使用 cpdf_adapter.cls.php 对于图像,在服务器中使用 pdflib_adapter.cls.php 作为图像。

After some analysis I found that in local it uses cpdf_adapter.cls.php for image, where as in server it uses pdflib_adapter.cls.php for image.

我甚至根据以下方式尝试了所有类型的图片:

I even tried for all the types of images according to:

pdfLib tutorial Version 8.0.2 ---page # 166--- Inline images are only supported for imagetype=ccitt, jpeg, and raw. For other image types the inline option will silently be ignored.

那么,导致此异常的问题是什么?

So, what is the problem that leads to this exception?

一些额外的信息:


  • 本地PHP版本5.3.0

  • 服务器PHP版本5.2.16

  • dompdf版本0.5.2

  • DOMPDF_TEMP_DIR具有r / w / e权限

  • 本地机器是windows vista

  • 服务器机器是linux

  • local PHP Version 5.3.0
  • server PHP Version 5.2.16
  • dompdf version 0.5.2
  • DOMPDF_TEMP_DIR has r/w/e permission
  • local machine is windows vista
  • server machine is linux

推荐答案

dompdf中存在一个与通过PDFLib添加图像相关的错误。我不确定即将发布的0.6.0版本是否已解决该问题。 支持小组上有相关主题。如果您想继续使用PDFLib,请查看我上一篇文章,了解有关解决方法的信息。

There was a bug in dompdf at some point related to adding images via PDFLib. I'm not sure if the issue has been addressed yet or not for the upcoming 0.6.0 release. There is a relevant thread on the support group. Take a look at my last post there for information on a work-around if you want to continue using PDFLib.

另一种选择是告诉dompdf使用CPDF。在dompdf_config.inc.php中将 DOMPDF_PDF_BACKEND 设置为CPDF而不是auto或PDFLib。

The other option would be to tell dompdf to use CPDF. In dompdf_config.inc.php set DOMPDF_PDF_BACKEND to "CPDF" instead of "auto" or "PDFLib".

这篇关于使用dompdf在pdf图像中出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆