php - PDF rendering issue using tcpdf


I’ve developed a feature in my application which takes some images and rendered to one pdf according to user. This functionality is working okay in my stage server but this shows me “server error” on production.

I verified error logs of apache and I found following errors

libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area

Corrupt JPEG data: 234 extraneous bytes before marker 0xd9

The application is created on cakephp, the library for rendering pdf is tcpdg and staging and production servers are on ubuntu. I’ve consult some senior guys, they all are saying this is GD problem.

The environment on stage server

PHP 5.3.3-0.dotdeb.1 with Suhosin-Patch (cli) (built: Oct  1 2010 08:49:29)
Copyright (c) 1997-2009 The PHP Group

The environment on production server

PHP 5.3.2-1ubuntu4.18 with Suhosin-Patch (cli) (built: Sep 12 2012 19:12:47)
Copyright (c) 1997-2009 The PHP Group

Please recommend me any risk free solution.




There are some garbage bytes after the end of the image for any reason which stop it to work.

You can do a work around to find "\xFF\xD9" in your image bytes which represents EOI (End of Image) and where ever you find it chop the bytes after it. Hopefully this will work.




During diagnosis this issue. I noticed that ImageMagick module wasn't loaded on our staging server. That's why it was working on staging server. We disabled it from production server and it works. It was causing some conflicts with GD.

I commented out following extension

Thanks anyways

People are also looking for solutions to the problem: php - Stop laravel controller action in another class


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.