Hello sivaramanm,

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.


In reply to Re: 'can't call method a"val" on an undefined value' error with PDF::API2 by McDarren
in thread 'can't call method a"val" on an undefined value' error with PDF::API2 by sivaramanm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.