in reply to 'can't call method a"val" on an undefined value' error with PDF::API2
I think you are a bit confused here. Firstly, it appears to me that you have simply copied/pasted the code example from the PDF::API2 synopsis, and expected it to somehow magically do what you want. That's not going to happen :)
You have $pdf = PDF::API2->new;, immediately followed by $pdf = PDF::API2->open('c:\temp.pdf');. So which is it? Are you creating a new PDF object/file, or opening an existing one?
You then do $page = $pdf->openpage($pagenum); - that is attempting to open a page at a non-defined page number (hence the error).
Finally, you have $img = $pdf->image_jpeg('siva.jpeg');. Now I may be wrong here (as I've not used this module before), but from a quick read of the docs I get the understanding that the image_jpeg method will create an image object from an EXISTING jpeg file. Which is probably the opposite to what you were expecting.
So it appears to me that PDF::API2 may not be able to do what you want, and you may instead need to look at ImageMagik's convert, as lorn suggested.
|
|---|