0

I have a PHP script which generates images from PDF pages using PHP Imagick. In which i write a piece of data on top of the image using annotateImage function and take it as output. This is failing recently on some PDF images being selected. I mean when a specific PDF is being given as input to this program the annotateImage function fails to write data where on many other PDF files it is performing well...

this is the following code which run on a loop to generate this images...

                $imagick->setResolution(200,200);
                $imagick->readImage('files/pdffile.pdf[1]');  
                $imagick->annotateImage($draw_small, 1250, 100, 10, 'Hello header');
                $imagick = $imagick->flattenImages();
                $file = fopen("/outputfile.jpg", 'w+');
                chmod($folder_in_action."/outputfile.jpg", 0755);
                fclose($file);
                $imagick->writeImage('/outputfile.jpg');

                $imagick->clear();

The code works well and get the exact PDF page as image in the folder but the annotateImage does not works on specific PDF files and so the output comes with no 'Hello header' message.

The same code works perfect on most of the PDF's where i get the specific PDF page with 'Hello header' message written on top as image...

So could not able to guess what could be the issue...

PDF file which does not allow annotateImage to write text is here:

http://wikisend.com/download/143652/notworking.pdf

PDF which is working (usually most of the pdf files are working properly...)

http://wikisend.com/download/215044/working.pdf

user2301765
  • 669
  • 2
  • 8
  • 22
  • "So could not able to guess what could be the issue..." And neither will anyone else be able to, unless you provide an reproducible example with a PDF that shows this problem. – Danack Apr 26 '17 at 09:35
  • @Danack - You are right. sorry about that. I updated the question with links to download the not working PDF and working PDF files... – user2301765 Apr 26 '17 at 13:58
  • Testing against those images, I get JPGs that have 'Hello header' written on both of them. I would suggest posting which exact versions of Ghostscript and ImageMagick are installed on your computer. – Danack May 07 '17 at 11:35

0 Answers0