1

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

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?

some additional info:

  • 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
Linger
  • 14,942
  • 23
  • 52
  • 79
sidhartha
  • 317
  • 2
  • 6
  • 15

1 Answers1

4

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.

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".

BrianS
  • 13,284
  • 15
  • 62
  • 125
  • 1
    thanks boss. i am really grateful to your commitment towards community. any way the above problem is solved after setting DOMPDF_PDF_BACKEND to "CPDF". but it created another problem in server.and the work around solution given in the thread link does not work for me. error is as follows **A PHP Error was encountered Severity: Warning Message: file_get_contents(http://myurl/logos/logo.png) [function.file-get-contents]: failed to open stream: Connection timed out Filename: lib/class.pdf.php Line Number: 4334** – sidhartha Feb 08 '11 at 11:20
  • Always glad to help. The message indicates a timeout, is "myurl/logos/logo.png" some placeholder text for the purposes of this post? Have you tried an image from another web site or via the local file system? – BrianS Feb 08 '11 at 18:28
  • yes myurl/logos/logo.png is the placeholder and i have tried images from local file system. i think this one is only due to incorrect path. though the above url shows the image directly on the browser it does not load it on pdf. – sidhartha Feb 09 '11 at 05:56
  • So the placeholder is a full URL including domain? I'm not sure why DOMPDF would run into a timeout problem if it works in the web browser, unless the server is having trouble looking up the domain. Is the PHP setting allow_url_fopen set to true? Can you try creating a stand-alone PHP script whose sole purpose is to open the file using `file_get_contents()`? This would at least let us know whether it's a dompdf or PHP issue. – BrianS Feb 09 '11 at 19:11