Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: PDF::API2 error when adding images to pdf

by jethro (Monsignor)
on Aug 20, 2009 at 15:33 UTC ( #790115=note: print w/replies, xml ) Need Help??

in reply to PDF::API2 error when adding images to pdf

There is a bug with your regexes. If you want to find a gif filename, you have to use something like this:

add_gif($file) if ($file =~ /\.gif$/);

Otherwise you will also find a file bgifblue.txt for example. The same problem is with the png and jpeg regexes

If this doesn't solve the issues, read on:

How many of your gifs (or pngs) cause the error? All of them or only one? If you look at the code in, it dies when it finds anything else but a 0xF9 after identifying a Graphics Control Extension, which seems to be used for specifiying the animation in animated gifs.

I can think of a few possibilities:

1) If you only have one gif with the problem, it likely is a corrupted gif.

2) If you have only one or a few gifs with the problem, it might be some never version of gif, where there could be something other than 0xF9 at that position

3) If all your gifs have this problem then the parser in is probably bugged

I checked the CPAN source of PDF::API2::Resource::XObject::Image for the png error and I don't see how an undefined value can surface there. Either I didn't see the bug or maybe you have an older version of any of the libraries PDF::API2::Resource::XObject::Image, PDF::API2::Basic::PDF::Utils, PDF::API2::Basic::PDF::Number or PDF::API2::Basic::PDF::String

Replies are listed 'Best First'.
Re^2: PDF::API2 error when adding images to pdf
by misterMatt (Novice) on Aug 20, 2009 at 18:11 UTC
    Wow you were absolutely right! I tightened up the regex patterns like you suggested, and I found and removed an animated gif. It works just fine now - a little slower than just jpeg files, but it works great. Thank you for your wonderful suggestions!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://790115]
and John Coltrane plays...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2017-02-27 02:51 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (376 votes). Check out past polls.