Page 1 of 1

Problem loading a PDF, annotating it and saving it to PDF

Posted: 2008-01-18T12:50:07-07:00
by justinhendrickson
I've been playing around with the ImageMagick PHP extension, Imagick, and I ran into a problem. I was trying to create an image by pull some PDFs in as images, add some text, then save the file to a new PDF. I don't get any problems creating the file, but when I tried to open the PDF with various programs, I got these results:

With Evince (Gnome document reader), it loads fine.
With acroread, I get "There was an error processing a page. There was a problem reading this document (14)."
With gs, I get "Error: /typecheck in --run--"

Eventually I was able to recreate the problem on the command line with a single command:

convert multipage.pdf -annotate 0x0+30+30 text out.pdf

The resulting PDF file exhibits the same problems I was having with Imagick. Interestingly, removing the -annotate portion results in a functioning PDF file. On a hunch, I removed my annotation calls in my PHP script and the PDF started working as well. Another interesting was that I'm able to convert the PDF, with annotation, to a PNM file, and then convert the PNM file to a PDF without a problem.

I've tried installing various versions of ImageMagick (6.2.4, 6.3.7-8, 6.3.7-9, 6.3.7-10, and svn) but all of them have the same problem.

Re: Problem loading a PDF, annotating it and saving it to PDF

Posted: 2008-01-18T13:24:36-07:00
by magick
Post a URL to your multipage.pdf file so we can download it and reproduce the problem. When we used our own multipage PDF file with your command, we got a valid out.pdf file.

Re: Problem loading a PDF, annotating it and saving it to PDF

Posted: 2008-01-18T13:38:42-07:00
by justinhendrickson
magick wrote:Post a URL to your multipage.pdf file so we can download it and reproduce the problem. When we used our own multipage PDF file with your command, we got a valid out.pdf file.
I'm going to feel very dumb if it was just the PDF file I was testing. :(

http://djcricket.com/imagick-pdf-test/l ... ar2008.pdf

UPDATE: I tried http://www.irs.gov/pub/irs-pdf/fw2.pdf as well and got a broken PDF.

Re: Problem loading a PDF, annotating it and saving it to PDF

Posted: 2008-01-18T17:28:00-07:00
by magick
We tried your image with ImageMagick 6.3.8-0 Beta and it converted fine and produced valid PDF output. 6.3.8-0 Beta is scheduled for release within a week or two.

Re: Problem loading a PDF, annotating it and saving it to PDF

Posted: 2008-01-18T17:51:53-07:00
by justinhendrickson
magick wrote:We tried your image with ImageMagick 6.3.8-0 Beta and it converted fine and produced valid PDF output. 6.3.8-0 Beta is scheduled for release within a week or two.
Is that version in your Subversion repository somewhere? I compiled revision 9100 from trunk this morning and it's what I've been doing all my tests against for the later half of this day.

Code: Select all

jhendric@jhendric-desktop:~/Desktop/ImageMagick$ svn info
Path: .
URL: https://www.imagemagick.org/subversion/ImageMagick/trunk
Repository Root: https://www.imagemagick.org/subversion
Repository UUID: aa41f4f7-0bf4-0310-aa73-e5a19afd5a74
Revision: 9100
Node Kind: directory
Schedule: normal
Last Changed Author: cristy
Last Changed Rev: 9098
Last Changed Date: 2008-01-17 20:08:37 -0600 (Thu, 17 Jan 2008)

Code: Select all

jhendric@jhendric-desktop:~/Desktop/ImageMagick$ convert -version
Version: ImageMagick 6.3.8 01/18/08 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2008 ImageMagick Studio LLC
Is there something else that might be causing this problem on my system? Maybe some dependency that I may have overlooked? I know that the version of ImageMagick in Ubuntu's repositories is ancient (6.2.4 or something). GhostScript seems up to date, so I'm not sure could be out of date.

Re: Problem loading a PDF, annotating it and saving it to PDF

Posted: 2008-01-18T18:12:33-07:00
by magick
The subversion trunk is ImageMagick 6.3.8-0 Beta. We're using Ghostscript 8.61. Not sure why you are having problems. We tried you PDF and command on 5 different OS's and could not reproduce the problem.

Re: Problem loading a PDF, annotating it and saving it to PDF

Posted: 2008-01-21T13:32:52-07:00
by justinhendrickson
magick wrote:The subversion trunk is ImageMagick 6.3.8-0 Beta. We're using Ghostscript 8.61. Not sure why you are having problems. We tried you PDF and command on 5 different OS's and could not reproduce the problem.
I've confirmed that the problem occurs on two different Ubuntu 7.10 machines as well as a Debian machine (not sure what version it is though). I also confirmed that it works on a FreeBSD virtual machine, so it would seem to be something Debian-based.