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

Howdy Monks,

I am displaying information from a db in several formats. I am now including PDF thanks to the suggestions given to me in response to this node. I am using PDF::Create. My code is working nicely now, but I have one little problem: The last page displays on the second to last. Currently, the output from page 3 is written over page 2, and page 3 is empty. The content for the first two pages is just fine.

If I create a page 4, then it all comes out correctly, but I am left with an extra page (page 4), which is empty. The only thing I can see that I am doing differently than the PDF::Create documentation, is creating the pages in an array, as follows:
my $root = $pdf->new_page(); my @page; $page[0] = $root->new_page(); $page[1] = $root->new_page(); $page[2] = $root->new_page();
This allows me increment the pages as necessary after checking if I am at the bottom of the page:
( $current_page, $ycoord ) = check_page( $current_page, $ycoord ); $page[$current_page]->string( $font, $size, $xcoord, $ycoord, "TEXT");
I have tested the value of $current_page at the relevant stages of the code, and while it is '2' (for the third page), the content still prints on page 2. I have also tried it with a hash instead of an array.

Anymonk have any ideas why I am having trouble with the pages?

bassplayer

Replies are listed 'Best First'.