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

pdf::api2 page question

by tonyperl (Initiate)
on Oct 01, 2005 at 00:45 UTC ( #496567=perlquestion: print w/replies, xml ) Need Help??

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

i just finished writing an invoice with pdf::api2. i start with a template that i open and print invoice line items to that page. when that page is full i create a new page. after printing several pages and just before i close/save the pdf and move on to the next doc, i'd like to figure out how many pages i have and then reference the first page and add page 1 of n pages to the bottom of the page. then i'd like to go to the next page and print page 2 of n pages etc... Does anyone know a good approach for doing this?

Replies are listed 'Best First'.
Re: pdf::api2 page question
by talexb (Chancellor) on Oct 01, 2005 at 03:43 UTC

    Umm .. Knowing that you have n pages, go back and iterate over the pages, adding Page m of n at the bottom of each page?

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

      For pages that I generate, my data is pre-processed from a database into an array of hashes. So each slot in the array is a page. No need to go back and place page numbers, just get the total page count from $#data, and then increment the current page number using a variable within the loop. This method may not work very well though if you are generating thousands of pages per document.
          This method may not work very well though if you are generating thousands of pages per document.

        Why not?

        Alex / talexb / Toronto

        "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

        thanks for the advice. i ended up making an array of pages and then at the end i cycled through the array and numbered the pages based on $pdf->pages; so i had something like $elementNumber of $pdf->pages; at the top of each page. i guess what i was trying to figure out is if this couldn't be done through the pdf object. i figured that every time a page object was created $pdf->page; the page would be put on a list owned by the pdf instance -- yeah totally goofy don't know what i was thinking...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2022-05-20 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (76 votes). Check out past polls.

    Notices?