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:
- use strict and warnings, I am guessing you are not using these, based on the fact that you do not declare $rows with my in the snippet provided.
- Indent Indent Indent, whatever scheme for indenting you wish to use is fine as long as it is consistent, this will make your code far easier for you and everyone else to read
- Variable names, everyone has their own opinion on good variable names however I don't think many people would like $_t_id. Abbreviations can save some time typing but if it hinders readability and understanding you have to ask is it worth it. In your example code $p_id I can guess to be product_id but $stat_id and $_t_id are not obvious, nor is ALL_MAN
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.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.