Hi Monks!
I followed a great node here -  http://www.perlmonks.org/?node_id=754777, Idid the updats on PDF::Table, works great, but having a problem trying to format my url to have the values of this array "@user_acc" been the account number parameter on my link. I can't figure it out how to do it, I am trying to get the array values using the number value of the variable $row, but I get an error, any help would be really helpful!!
Here is the code sample I have:

#!/usr/bin/perl use strict; use warnings; use PDF::API2; use PDF::Table; my $pdftable = new PDF::Table; my $pdf = new PDF::API2(-file => "test.pdf"); $pdf->preferences( -thumbs => 1, ); my $page_num = 1; my @user_acc = ("23457", "23467", "29989","23957", "20467", "39989"," +7723457", "013467", "288989"); # some data to layout my $some_data =[ ["Name", "Address", "City", "State", "Zip", "Phone", "Address 2", "Address 3", "Address 4", "Email", ], # content, 70 rows x 10 columns map { my $row = $_; [ map "$_", 1..10 ] } 1..70, ]; main_table($pdf, $some_data); $pdf->saveas(); ############## ###### ##### sub main_table { my $pdf = shift; my $data = shift; my $page = newpage(); # first page my $col_props = [ map{ #{}, # This is an empty hash so the next one will hold the propert +ies for the second row from left to right. { min_w => 5, # Minimum column width. justify => 'center', # One of left|right , font => $pdf->corefont("Times", -encoding => "latin1"), font_size => 5, font_color=> '#003366', background_color => '#000000', }, # etc. } 1..10, ]; # build the table layout $pdftable->table( # required params $pdf, $page, $data, x => 5, w => 780, start_y => 537, # 550 next_y => 537, start_h => 500, next_h => 500, # some optional params #max_word_length=> 20, # add a space after every 20th symbol in +long words like serial numbers padding => 1, # cell padding padding_top => 2, # top cell padding, overides padding padding_right => 2, # right cell padding, overides padding padding_left => 2, # left cell padding, overides padding padding_bottom => 2, # bottom padding, overides -padding border => 1, # border width, default 1, use 0 for no bo +rder border_color => '#000000', # default black font => $pdf->corefont("Helvetica", -encoding => "utf8") +, # default font #font => $pdf->corefont("Times", -encoding => "latin1"), background_color => '#FFFF00', font_size => 7, font_color_odd => '#000000', font_color_even=> '#000000', background_color_odd => '#e0e0e0', #gray cell background colo +r for odd rows - #d2d2d2 background_color_even => '#ffffff', #lightblue cell background + color for even rows new_page_func => \&newpage, # as defined above cell_render_hook => sub { # this is our newly introduced ca +llback function my ($page, $row, $col, $x, $y, $w, $h) = @_; #if ($col == 0) { # do nothing except for first column #my $c=0; if (( $col == 0) && ($row >= 1) ) { # do nothing except f +or first column #$c++; my $url = "http://www.mysite.com?test=$row&useraccount +=$user_acc[$row]"; # where my problem is, can't get all the user_acc +for each row here. my $annot = $page->annotation(); $annot->url( $url, -rect => [$x, $y, $x+$w, $y+$h], -border => [1,1,1] ); } }, #header_props => { repeat => 1}, header_props => { font => $pdf->corefont("Helvetica", -encodi +ng => "uft8"), font_size => 7, font_color => '#ffffff', bg_color => '#003366', repeat => 1, }, #column_props => $col_props, column_props => [ map{{justify => 'center' }}1..10, ], ); } sub newpage { my $page = $pdf->page; $page->mediabox(792,612); header($page); footer($page); page_nr($page, $page_num++); return $page; } sub header { my $page = shift; # we need a page to place ourselves on my $head_data =[ ["User Information",], ["Data 1",], ["Auto Report System",] ]; $pdftable->table( # required params $pdf, $page, $head_data, x => 20, w => 750, start_y => 594, # top od doc on page - 594 next_y => 594, start_h => 100, next_h => 100, #OPTIONAL PARAMS BELOW #max_word_length=> 20, # add a space after every 20th symbo +l in long words like serial numbers padding => 3, # cell padding padding_top => 1, # top cell padding, overides padding #padding_right => 1, # right cell padding, overides paddi +ng #padding_left => 5, # left cell padding, overides paddin +g #padding_bottom => 5, # bottom padding, overides -padding border => 1, # border width, default 1, use 0 for + no border border_color => '#ffffff', # default black #font => $pdf->corefont("Helvetica", -encoding => " +utf8"), # default font #font_size => 10, #font_color_odd => 'black', #font_color_even=> 'black', #background_color_odd => "#ffffff", #background_color_even => "#003366", #cell background color f +or even rows #header_props => $hdr_props, column_props => [ { justify => 'center' } ], ); } sub footer { my $page = shift; # we need a page to place ourselves on my $footer_data =[ [ get_date() ] ]; $pdftable->table( # required params $pdf, $page, $footer_data, x => 20, w => 750, start_y => 30, # top od doc on page next_y => 30, start_h => 30, next_h => 30, #OPTIONAL PARAMS BELOW #max_word_length=> 20, # add a space after every 20th symbo +l in long words like serial numbers padding => 1, # cell padding border => 1, # border width, default 1, use 0 for + no border border_color => '#ffffff', # default black font => $pdf->corefont("Helvetica", -encoding => "u +tf8"), # default font font_size => 7, #header_props => $hdr_props, column_props => [ { justify => 'center' } ], ); } sub page_nr { my $page = shift; my $num = shift; $page->gfx->textlabel( # PDF::API2 method 760, 15, # x, y $pdf->corefont("Helvetica"), 8, # font, size "Page $num", # text -color => '#808080', -align => 'right', ); } sub get_date { my ($mon, $mday, $year) = (localtime)[4,3,5]; return sprintf '%02d-%02d-%04d', $mon+1, $mday, $year+1900; }


Thanks for the help!!!

In reply to URL issue with PDF::Table by Anonymous Monk

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.