Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Adding Image to PDF

by MilanorTSW (Beadle)
on Oct 10, 2012 at 16:06 UTC ( #998252=note: print w/ replies, xml ) Need Help??

in reply to Adding Image to PDF

You'll have to use the gfx object method for that, AFAIK.

my $gfx = $page->gfx; my $img = $pdf->image("images/logo.jpeg", 100, 60); # define the image + and image dimensions $gfx->image($img, $x, $y); # Add the image, including coordinates $gfx->close; # close up

Comment on Re: Adding Image to PDF
Download Code
Replies are listed 'Best First'.
Re^2: Adding Image to PDF
by Anonymous Monk on Oct 10, 2012 at 17:23 UTC
    No luck, tried and getting an error:
    Can't locate object method "image" via package "PDF::API2" at +line 32.

    If I change this line:
    my $img = $pdf->image("images/logo.jpeg", 100, 60); # define the image + and image dimensions

    my $img = $pdf->image_jpeg("images/logo.jpeg", 100, 60); # define the +image and image dimensions

    I am getting this:
    Can't call method "val" on an undefined value at /usr/local/share/perl +5/PDF/API2/Resource/XObject/ line 66.

    Any more input? Thanks!
      The last error generally means that such image does not exist and as such the value is left unidentified. Are you sure the image is there? Also try $gfx->stroke; and $gfx->compress(); after closing.
        I got it to work, now one last issue, I would like the logo to be placed next to the heading's words, any ideas?
        ... my $logo = "images/logo.gif"; my $image = $pdf->image_gif($logo, 150, 50); my $gfx = $page->gfx; $gfx->image($image, 10, 750); my $head_data =[ #this will not work #[$gfx->image($image, 10, 750),], ["Add Logo here",]' ["My Company Name",], ["USA",], ["Customers",], ]; $pdftable->table( # required params $pdf, $page, $head_data, x => 20, w => 750, start_y => 605, next_y => 594, start_h => 100, next_h => 100, column_props => [ { justify => 'left' } ], ); ...

        Thanks for the help@

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://998252]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2015-10-06 19:37 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (159 votes), past polls