As you have provided incomplete code with no example data and no error messages, it is difficult to say where your problem is.

The documentation for PDF::Table indicates that your data should be in an array.

It can be used to display text data in a table layout within the PDF. The text data must be in a 2d array (such as returned by a DBI statement handle fetchall_arrayref() call).
Perhaps if you loop over your data to construct your array then pass that to generate the table in the pdf, it will do what you want.

Here is a rough example of how your code could be modified, as the code is incomplete this is untested.

my @tabledata; foreach my $ship_prod (@SHIP_PRODS){ my($_t_id,$p_id,$stat_id,$qty) = split(/$SEP_CHAR/,$ship_prod); $rows = ["", "$ALL_PRODS{$p_id}",""]; if(exists($ALL_MAN{$p_id}) && length($ALL_MAN{$p_id}) > 0){ $rows = ["", "$ALL_MAN{$p_id}",""]; } push @tabledata, $rows; } # build the table layout $pdftable->table( # required params $pdf, $page, \@tabledata, x => 5, start_y => 470, next_y => 450, start_h => 200, next_h => 250, # some optional params w => 600, padding => 5, padding_right => 10, font_size => 8, )

A few brief pointers on your code:

A tip for submitting questions to PerlMonks, break your problem down into a small but complete example that can be executed to see the exact error.


In reply to Re: Looping in PDF::Table module by rnewsham
in thread Looping in PDF::Table module by divinafaudan

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.