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


In reply to PDF::Create page question by bassplayer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.