trevelyn has asked for the wisdom of the Perl Monks concerning the following question:

Heyas! Long time no see! I have a small problem with understanding CPAN errors which seem to happen more than successful installs. I just need to make my Perl Tk application make a nice PDF output using a simple PDF module that is easy to install for my friends. So far PDF::API2 was the only one that actually installed via CPAN. and I feel like it is popular enough to be in peoples precompiled software repositories in their OS's. Anyways, my question for you guys is: Can i place an image into my media area without it stretching out and blurring?? I create my page, then i create my image handler, then gfx(), then put the image into the gfx ad absurdum.
$page = $pdf->new; $mylol = $pdf->image_png("lmfao.png"); $gfx = $pdf->gfx(); $gfx->image($mylol, <posx>, <posy>); ...
and the image stretches out really bad from end to end :( Thanks in Advance! ~Trevelyn.

Replies are listed 'Best First'.
Re: pdf::api2 scale images?
by biohisham (Priest) on Jun 19, 2010 at 05:14 UTC
    How are you initializing your $page variable?, isn't it supposed to be $page = $pdf->page where $pdf is the PDF::API object that was created via the new() method?

    "I have a small problem with understanding CPAN errors "
    It's worrisome that strictures don't seem to be switched on..
    use strict; use warnings;
    and heed the messages generated thereof.

    You may also need to consult Tk::Photo...


    Excellence is an Endeavor of Persistence. A Year-Old Monk :D .
      oh, I'm sorry I failed to put a "..." at the top of the code. This is just a piece of code I dropped off the top of my head. I do use warnings in all of my code, and I had a problem using strict with some Tk modules, so I took it out. I didn't realize that PDF::API2::Content came with PDF::API2, or I would have checked the CPAN link above. I did know it existed, I just thought that was yet another dependency my friends would need to install and skipped it. So far the PDF generation is smooth and they look great! Now with the $scale and PDF::API2::Content $gfx()->image $img $x $y $scale -- I'm sure things will be much much nicer! :) Thanks guys!
Re: pdf::api2 scale images?
by Khen1950fx (Canon) on Jun 19, 2010 at 02:20 UTC
    Your script isn't exactly ready for prime-time. I'd recommend reading the documentation for PDF::API2.

      You would be better off reading the Content module documentation, specifically the part under "GRAPHICS METHODS" where is says: $gfx->image $imgobj, $x,$y, $scale;