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

I am using PDF::API2 and PDF::Reuse. to create a pdf file using existing pdf files and some text data. I like to put page number on each page and need help for the same. Do I have to use prText() or there is some standard way?

Replies are listed 'Best First'.
Re: PDF Page numbers
by kvale (Monsignor) on Mar 14, 2005 at 20:48 UTC
    There is no standard way to add page numbers or other header or footer data to PDF documents. This is because PDF is just a printing format; it has no knowledge of the graphical layout rules of the program that produced it.

    So the best way is probably to use prText() at an (x,y) location of your choosing and keep it consistent throughout your document. If your document opens like book or magazine, then positions of the page numbers should be set spearately for the left and right facing pages, e.g., lower left corner for left ages and lower right corner for right pages.

    -Mark

      Thanks Mark, I am trying to put it together. I like to paginate every page of Infile. The following code gives some type of problem. I have 9 pages in the infile, and it gives page numbers to 5 pages only and erase original data after page 1.

      use PDF::Reuse; use strict; my $infile = 'in.pdf'; my $outfile = 'out.pdf'; prFile($outfile); my $count; my $page = 1; prFont('Courier-Bold'); # Sets font prFontSize(20); # And font size while(1){ $count = prDoc({ file => $infile, first => $page, last => $page , # page => $page }); last if $count == 0; prText(250,50, "Page:$page"); prPage(); $page += 1; } prEnd();

      Appreciate some help
      Thanks