Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Error when trying to loop through DB and run a script

by mreece (Friar)
on Apr 03, 2007 at 16:48 UTC ( [id://608103]=note: print w/replies, xml ) Need Help??


in reply to Error when trying to loop through DB and run a script

i suspect the problem is in the PDF code which you did not post. i recommend you trim your PDF Stuff down to something small that still produces the error, and troubleshoot that.

specifically, it appears that your $api object has an undef $api->{pdf} value. are you properly constructing a new PDF::API2 object each time through your while loop?

Replies are listed 'Best First'.
Re^2: Error when trying to loop through DB and run a script
by ikkon (Monk) on Apr 03, 2007 at 17:20 UTC
    you know I probably not, But I thought each time through the pdf objects where distroyed?? I figured out where its failing, just not sure what I am doing wrong, you are probably on to something with the $pdf object, but not sure how to do it here is code where the problem lies:
    my $ChartImageName = "$tmpPath/VeTCOChart.png"; setImage($ChartImageName, 110/mm, 165/mm, 95.25/mm, 79.375/mm); sub setImage{ my $photo_file=$pdf->image_png($_[0] ,-lossless => 1); my $photo = $page->gfx; ## add photo to pdf include cordinates and size - image($photo, x, + y, width, hieght); $photo->image($photo_file, $_[1], $_[2], $_[3], $_[4]); }
    setimage call is where its failing! I open a pdf template so this is how I declare my pdf object.
    my $pdf = PDF::API2->open($Template) or print "PDF Object is failing o +r NULL"; my $page = $pdf->openpage(1);
    thanks for the help
      this code appears out of order, perhaps, so i'm not sure what is going on. my guess is that the my $pdf = ... is at file scope, so setImage() is reusing the same $pdf object every time, and it probably shouldn't. consider creating a fresh PDF::API2 object each time through your while loop, and passing it explicitely to the setImage function.
        yep this is it, i declared pdf globaly and it worked, thanks.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-19 11:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found