Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: PDF::API2 is confusing me to death..

by mpeters (Chaplain)
on Sep 02, 2005 at 17:24 UTC ( #488718=note: print w/ replies, xml ) Need Help??


in reply to PDF::API2 is confusing me to death..

I you want to add a new page, you are correct in using the $pdf->page() method, but you need to tell it what page to create. By default it will just give you the first page (and create it if it doesn't exist). So doing something like this (untested):

$page_num = 1; while ($files[$counter] ne "") { print("Encoding $files[$counter] to PDF format\n"); open(INFILE, "$startdir/$files[$counter]"); $line=<INFILE>; while($line ne "") { $txt->translate($xc,$yc); $yc-=10; if($yc==0){ $pdf->page($page_count); $txt = $page->hybrid; $txt->textstart; $txt->font($fnt, 10); $page->mediabox('LETTER'); $yc=780; } $txt->text($line); $counter++; $line=<INFILE>; } }
Is probably more like what you want.

-- More people are killed every year by pigs than by sharks, which shows you how good we are at evaluating risk. -- Bruce Schneier


Comment on Re: PDF::API2 is confusing me to death..
Select or Download Code
Re^2: PDF::API2 is confusing me to death..
by Bentov (Novice) on Sep 06, 2005 at 18:26 UTC
    Hmmm, I am able to create multiple pages, but the text just writes over itself on the 1st page. I have some problems with your code,but I see where you are going with it, I'll try to make some mods to my program. I guess though I still have the problem that I don't understand what is supposed to select the second page. I know what creates the additional pages, but what says "hey, write to me now buddy!" Bentov
      I know what creates the additional pages, but what says "hey, write to me now buddy!"
      That's what the openpage() method does. It will return the page object. From that you can add whatever you want to that page. This is how I usually do that:
      my $current_page = $pdf->openpage($page_num); $current_page->gfx->textlabel( 100, # X coord 200, # Y coord $font, $font_size, "Some text to write", ); $current_page->update();

      -- More people are killed every year by pigs than by sharks, which shows you how good we are at evaluating risk. -- Bruce Schneier

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-08-01 03:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (256 votes), past polls