Problems with table position in a PDF using PDF::Table

Discussion in 'Perl Misc' started by Ted Byers, Dec 3, 2008.

  1. Ted Byers

    Ted Byers Guest

    Here is the relevant part of the documentation:

    ($end_page, $pages_spanned, $table_bot_y) = $pdftable->table(
    $pdf, # A PDF::API2 instance
    $page_to_start_on, # A PDF::API2::page instance created with
    $page_to_start_on = $pdf->page();
    $data, # 2D arrayref of text strings
    x => $left_edge_of_table, #X - coordinate of upper left
    corner
    w => 570, # width of table.
    start_y => $initial_y_position_on_first_page,
    next_y => $initial_y_position_on_every_new_page,
    start_h => $table_height_on_first_page,
    next_h => $table_height_on_every_new_page,
    ....
    }

    Notice the specification of the meaning of next_y!

    Here is what I have in my code:

    ($end_page, $pages_spanned, $table_bot_y) = $pdftable->table(
    $pdf,
    $page,
    \@table2,
    x=>$x,
    w=>555,
    start_y=>$y,
    next_y=>$900,
    start_h=> 250,
    next_h=>500,
    # optional parameters
    padding =>2,
    header_props=>$hdr_props,
    column_props=>$col_propsM2,
    );

    No matter what values I give next_y or next_h, the continuation of the
    table on the second page is ALWAYS placed in the middle of the page.

    What I would really like to happen is to always have the continuation
    of the table start at the top of the next page and to fill the page if
    there is sufficient data. However, I have yet to find the magic
    required to make that happen in the documentation for PDF::Table (the
    package I am using for this).

    Can anyone tell me either what I missed (is there relevant information
    elsewhere than the man page for PDF::Table) or how I might fix or work
    around this?

    Thanks

    Ted
     
    Ted Byers, Dec 3, 2008
    #1
    1. Advertising

  2. Ted Byers

    Guest

    On Wed, 3 Dec 2008 13:32:18 -0800 (PST), Ted Byers <> wrote:

    >Here is the relevant part of the documentation:
    >
    >($end_page, $pages_spanned, $table_bot_y) = $pdftable->table(
    > $pdf, # A PDF::API2 instance
    > $page_to_start_on, # A PDF::API2::page instance created with
    >$page_to_start_on = $pdf->page();
    > $data, # 2D arrayref of text strings
    > x => $left_edge_of_table, #X - coordinate of upper left
    >corner
    > w => 570, # width of table.
    > start_y => $initial_y_position_on_first_page,
    > next_y => $initial_y_position_on_every_new_page,
    > start_h => $table_height_on_first_page,
    > next_h => $table_height_on_every_new_page,
    >...
    >}
    >
    >Notice the specification of the meaning of next_y!
    >
    >Here is what I have in my code:
    >
    > ($end_page, $pages_spanned, $table_bot_y) = $pdftable->table(
    > $pdf,
    > $page,
    > \@table2,
    > x=>$x,
    > w=>555,
    > start_y=>$y,
    > next_y=>$900,
    > start_h=> 250,
    > next_h=>500,
    ># optional parameters
    > padding =>2,
    > header_props=>$hdr_props,
    > column_props=>$col_propsM2,
    > );
    >

    I don't know this package. But, do you notice that
    you have an ODD number of parameters passed to
    $pdftable->table ??

    Usually, a package writer parses such input in pairs.
    Unless say after \@table2, he is taking optional @args in pairs.
    ie:

    sub table
    {
    my ($self,$pdf,$page,$arrayref,@args) = @_;
    }


    sln
     
    , Dec 3, 2008
    #2
    1. Advertising

  3. Ted Byers

    Ted Byers Guest

    On Dec 3, 4:32 pm, Ted Byers <> wrote:
    > Here is the relevant part of the documentation:
    >
    > ($end_page, $pages_spanned, $table_bot_y) = $pdftable->table(
    >      $pdf,               # A PDF::API2 instance
    >      $page_to_start_on,  # A PDF::API2::page instance created with
    > $page_to_start_on = $pdf->page();
    >      $data,              # 2D arrayref of text strings
    >      x  => $left_edge_of_table,    #X - coordinate of upperleft
    > corner
    >      w  => 570, # width of table.
    >      start_y => $initial_y_position_on_first_page,
    >      next_y  => $initial_y_position_on_every_new_page,
    >      start_h => $table_height_on_first_page,
    >      next_h  => $table_height_on_every_new_page,
    > ...
    >
    > }
    >
    > Notice the specification of the meaning of next_y!
    >
    > Here is what I have in my code:
    >
    >   ($end_page, $pages_spanned, $table_bot_y) = $pdftable->table(
    >                  $pdf,
    >                  $page,
    >                  \@table2,
    >                  x=>$x,
    >                  w=>555,
    >                  start_y=>$y,
    >                  next_y=>$900,
    >                  start_h=> 250,
    >                  next_h=>500,
    > # optional parameters
    >                  padding =>2,
    >                  header_props=>$hdr_props,
    >                  column_props=>$col_propsM2,
    >   );
    >
    > No matter what values I give next_y or next_h, the continuation of the
    > table on the second page is ALWAYS placed in the middle of the page.
    >
    > What I would really like to happen is to always have the continuation
    > of the table start at the top of the next page and to fill the page if
    > there is sufficient data.  However, I have yet to find the magic
    > required to make that happen in the documentation for PDF::Table (the
    > package I am using for this).
    >
    > Can anyone tell me either what I missed (is there relevant information
    > elsewhere than the man page for PDF::Table) or how I might fix or work
    > around this?
    >
    > Thanks
    >
    > Ted


    A new observation related to this.

    On increasing the amount of data to stress the code, and playing with
    the mouse wheel, I noticed that the top of the table in question when
    it is continued on the second page is precisely in line with the top
    of the table as it appears on the first page, almost as if the next_y
    parameter is ignored.

    While I wait for a response, I will look into the code for PDF::Table,
    much as I hate to debug someone else's code, to see if I can spot a
    problem there.

    I will report back here if I find something.

    Cheers

    Ted
     
    Ted Byers, Dec 3, 2008
    #3
  4. Ted Byers

    Ted Byers Guest

    On Dec 3, 5:25 pm, wrote:
    > On Wed, 3 Dec 2008 13:32:18 -0800 (PST), Ted Byers <> wrote:
    > >Here is the relevant part of the documentation:

    >
    > >($end_page, $pages_spanned, $table_bot_y) = $pdftable->table(
    > >     $pdf,               # A PDF::API2 instance
    > >     $page_to_start_on,  # A PDF::API2::page instance created with
    > >$page_to_start_on = $pdf->page();
    > >     $data,              # 2D arrayref of text strings
    > >     x  => $left_edge_of_table,    #X - coordinate of upper left
    > >corner
    > >     w  => 570, # width of table.
    > >     start_y => $initial_y_position_on_first_page,
    > >     next_y  => $initial_y_position_on_every_new_page,
    > >     start_h => $table_height_on_first_page,
    > >     next_h  => $table_height_on_every_new_page,
    > >...
    > >}

    >
    > >Notice the specification of the meaning of next_y!

    >
    > >Here is what I have in my code:

    >
    > >  ($end_page, $pages_spanned, $table_bot_y) = $pdftable->table(
    > >                 $pdf,
    > >                 $page,
    > >                 \@table2,
    > >                 x=>$x,
    > >                 w=>555,
    > >                 start_y=>$y,
    > >                 next_y=>$900,
    > >                 start_h=> 250,
    > >                 next_h=>500,
    > ># optional parameters
    > >                 padding =>2,
    > >                 header_props=>$hdr_props,
    > >                 column_props=>$col_propsM2,
    > >  );

    >
    > I don't know this package. But, do you notice that
    > you have an ODD number of parameters passed to
    >  $pdftable->table ??
    >
    > Usually, a package writer parses such input in pairs.
    > Unless say after \@table2, he is taking optional @args in pairs.
    > ie:
    >
    > sub table
    > {
    >         my ($self,$pdf,$page,$arrayref,@args) = @_;
    >
    > }
    >
    > sln- Hide quoted text -
    >
    > - Show quoted text -


    Yes, but that is the way he documents this package to work.

    It seems clear to me that the first three arguments are required in
    the order provided and that the remaining arguments are held in a
    hash. His documentation wouldn't make sense otherwise. While I have
    not yet looked at his code, my guess is that he strips off the first
    three arguments and then places the remaining arguments in a hash.

    Thanks

    Ted
     
    Ted Byers, Dec 3, 2008
    #4
  5. Ted Byers

    Jim Gibson Guest

    In article
    <>,
    Ted Byers <> wrote:


    > Here is what I have in my code:
    >
    > ($end_page, $pages_spanned, $table_bot_y) = $pdftable->table(
    > $pdf,
    > $page,
    > \@table2,
    > x=>$x,
    > w=>555,
    > start_y=>$y,
    > next_y=>$900,


    Is that really '$900' in your code? That is probably undefined (unless
    you have a very long regular expression in your code.)

    > start_h=> 250,
    > next_h=>500,
    > # optional parameters
    > padding =>2,
    > header_props=>$hdr_props,
    > column_props=>$col_propsM2,
    > );


    --
    Jim Gibson
     
    Jim Gibson, Dec 3, 2008
    #5
  6. Ted Byers

    Guest

    On Wed, 3 Dec 2008 14:33:31 -0800 (PST), Ted Byers <> wrote:

    >On Dec 3, 5:25 pm, wrote:
    >> On Wed, 3 Dec 2008 13:32:18 -0800 (PST), Ted Byers <> wrote:
    >> >Here is the relevant part of the documentation:

    >>

    [snip]
    >Yes, but that is the way he documents this package to work.
    >
    >It seems clear to me that the first three arguments are required in
    >the order provided and that the remaining arguments are held in a
    >hash. His documentation wouldn't make sense otherwise. While I have
    >not yet looked at his code, my guess is that he strips off the first
    >three arguments and then places the remaining arguments in a hash.
    >

    Or, splice the array by 2's, which is easier to control for name
    manipulation and to aviod even'es hash requirements.

    sln
     
    , Dec 3, 2008
    #6
  7. Ted Byers

    Guest

    On Wed, 03 Dec 2008 14:57:38 -0800, Jim Gibson <> wrote:

    >In article
    ><>,
    >Ted Byers <> wrote:
    >
    >
    >> Here is what I have in my code:
    >>
    >> ($end_page, $pages_spanned, $table_bot_y) = $pdftable->table(
    >> $pdf,
    >> $page,
    >> \@table2,
    >> x=>$x,
    >> w=>555,
    >> start_y=>$y,
    >> next_y=>$900,

    >
    >Is that really '$900' in your code? That is probably undefined (unless
    >you have a very long regular expression in your code.)
    >
    >> start_h=> 250,
    >> next_h=>500,
    >> # optional parameters
    >> padding =>2,
    >> header_props=>$hdr_props,
    >> column_props=>$col_propsM2,
    >> );

    $900, holy cow..
     
    , Dec 3, 2008
    #7
  8. Ted Byers

    Ted Byers Guest

    On Dec 3, 5:57 pm, Jim Gibson <> wrote:
    > In article
    > <>,
    >
    > Ted Byers <> wrote:
    > > Here is what I have in my code:

    >
    > >   ($end_page, $pages_spanned, $table_bot_y) = $pdftable->table(
    > >                  $pdf,
    > >                  $page,
    > >                  \@table2,
    > >                  x=>$x,
    > >                  w=>555,
    > >                  start_y=>$y,
    > >                  next_y=>$900,

    >
    > Is that really '$900' in your code? That is probably undefined (unless
    > you have a very long regular expression in your code.)
    >
    > >                  start_h=> 250,
    > >                  next_h=>500,
    > > # optional parameters
    > >                  padding =>2,
    > >                  header_props=>$hdr_props,
    > >                  column_props=>$col_propsM2,
    > >   );

    >
    > --
    > Jim Gibson


    Yes. A typo. I am surprised, though, that it went undetected given
    that the first line of the script is "use strict;" Is that a fluke,
    or are there times when use strict won't catch an undeclared variable?

    Thanks for spotting that.

    Ted
     
    Ted Byers, Dec 4, 2008
    #8
  9. Ted Byers

    Uri Guttman Guest

    >>>>> "TB" == Ted Byers <> writes:

    TB> On Dec 3, 5:57 pm, Jim Gibson <> wrote:
    >> >                  next_y=>$900,

    >>
    >> Is that really '$900' in your code? That is probably undefined (unless
    >> you have a very long regular expression in your code.)


    TB> Yes. A typo. I am surprised, though, that it went undetected given
    TB> that the first line of the script is "use strict;" Is that a fluke,
    TB> or are there times when use strict won't catch an undeclared variable?

    strict will detect undeclared vars. that $900 is as jim said a very
    large numbered grab variable which never needs declaring. it would be
    undef which is valid as a hash value. now if you interpolated it or did
    some other stuff it would trigger a warning if warnings were enabled.

    uri

    --
    Uri Guttman ------ -------- http://www.sysarch.com --
    ----- Perl Code Review , Architecture, Development, Training, Support ------
    --------- Free Perl Training --- http://perlhunter.com/college.html ---------
    --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
     
    Uri Guttman, Dec 4, 2008
    #9
  10. Ted Byers

    Ted Byers Guest

    On Dec 3, 9:19 pm, Uri Guttman <> wrote:
    > >>>>> "TB" == Ted Byers <> writes:

    >
    >   TB> On Dec 3, 5:57 pm, Jim Gibson <> wrote:
    >   >> >                  next_y=>$900,
    >   >>
    >   >> Is that really '$900' in your code? That is probably undefined (unless
    >   >> you have a very long regular expression in your code.)
    >
    >   TB> Yes.  A typo.  I am surprised, though, that it went undetected given
    >   TB> that the first line of the script is "use strict;"  Is that a fluke,
    >   TB> or are there times when use strict won't catch an undeclared variable?
    >
    > strict will detect undeclared vars. that $900 is as jim said a very
    > large numbered grab variable which never needs declaring. it would be
    > undef which is valid as a hash value. now if you interpolated it or did
    > some other stuff it would trigger a warning if warnings were enabled.
    >
    > uri
    >
    > --
    > Uri Guttman  ------    --------  http://www.sysarch.com--
    > -----  Perl Code Review , Architecture, Development, Training, Support ------
    > --------- Free Perl Training ---http://perlhunter.com/college.html---------
    > ---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com---------


    Ah, OK. Learned something new today.

    Thanks

    Ted
     
    Ted Byers, Dec 4, 2008
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luqman
    Replies:
    1
    Views:
    657
    Luqman
    Feb 7, 2006
  2. James Wong
    Replies:
    4
    Views:
    503
    James Wong
    Jul 14, 2004
  3. Replies:
    3
    Views:
    184
  4. James Black
    Replies:
    0
    Views:
    403
    James Black
    May 28, 2006
  5. brendan
    Replies:
    0
    Views:
    199
    brendan
    Aug 29, 2006
Loading...

Share This Page