- }
- #TODO: Add code for header props compatibility and col_props comp....
- #####
- my ( $xbase, $ybase, $width, $height ) = ( undef, undef, undef, undef );
- # Could be 'int' or 'real' values
- $xbase = $arg{'x' } || -1;
- $ybase = $arg{'start_y'} || -1;
- $width = $arg{'w' } || -1;
- $height = $arg{'start_h'} || -1;
-
- # Global geometry parameters are also mandatory.
- unless ( $xbase > 0 ) { print "Error: Left Edge of Table is NOT defined!\n"; return; }
- unless ( $ybase > 0 ) { print "Error: Base Line of Table is NOT defined!\n"; return; }
- unless ( $width > 0 ) { print "Error: Width of Table is NOT defined!\n"; return; }
- unless ( $height > 0 ) { print "Error: Height of Table is NOT defined!\n"; return; }
-
- # Ensure default values for -next_y and -next_h
- my $next_y = $arg{'next_y'} || $arg{'start_y'} || 0;
- my $next_h = $arg{'next_h'} || $arg{'start_h'} || 0;
-
- # Create Text Object
- my $txt = $page->text;
- # Set Default Properties
- my $fnt_name = $arg{'font'} || $pdf->corefont('Times', -encode => 'utf8');
- my $fnt_size = $arg{'font_size'} || 12;
- my $max_word_len = $arg{'max_word_length'} || 20;
-
- #=====================================
- # Table Header Section
- #=====================================
- # Disable header row into the table
- my $header_props;
- my $num_header_rows = 0;
- my @header_rows;
- # Check if the user enabled it ?
- if (defined $arg{'header_props'} and ref( $arg{'header_props'}) eq 'HASH') {
- # Transfer the reference to local variable
- $header_props = $arg{'header_props'};
- # Check other params and put defaults if needed
- $header_props->{'repeat'} = $header_props->{'repeat'} || 0;
- $header_props->{'font'} = $header_props->{'font'} || $fnt_name;
- $header_props->{'font_color'} = $header_props->{'font_color'} || '#000066';
- $header_props->{'font_size'} = $header_props->{'font_size'} || $fnt_size + 2;
- $header_props->{'bg_color'} = $header_props->{'bg_color'} || '#FFFFAA';
-
- $num_header_rows = $arg{'num_header_rows'} || 1;
- }
- #=====================================
- # Other Parameters check
- #=====================================
-
- my $lead = $arg{'lead'} || $fnt_size;
- my $pad_left = $arg{'padding_left'} || $arg{'padding'} || 0;
- my $pad_right = $arg{'padding_right'} || $arg{'padding'} || 0;
- my $pad_top = $arg{'padding_top'} || $arg{'padding'} || 0;
- my $pad_bot = $arg{'padding_bottom'} || $arg{'padding'} || 0;
- my $pad_w = $pad_left + $pad_right;
- my $pad_h = $pad_top + $pad_bot ;
- my $line_w = defined $arg{'border'} ? $arg{'border'} : 1 ;
-
- my $background_color_even = $arg{'background_color_even'} || $arg{'background_color'} || undef;
- my $background_color_odd = $arg{'background_color_odd'} || $arg{'background_color'} || undef;
- my $font_color_even = $arg{'font_color_even'} || $arg{'font_color'} || 'black';
- my $font_color_odd = $arg{'font_color_odd'} || $arg{'font_color'} || 'black';
- my $border_color = $arg{'border_color'} || 'black';
-
- my $min_row_h = $fnt_size + $pad_top + $pad_bot;
- my $row_h = defined ($arg{'row_height'}) && ($arg{'row_height'} > $min_row_h) ? $arg{'row_height'} : $min_row_h;
-
- my $pg_cnt = 1;
- my $cur_y = $ybase;
- my $cell_props = $arg{cell_props} || []; # per cell properties
- my $row_cnt = $num_header_rows;
-
- #If there is valid data array reference use it!
- if (ref $data eq 'ARRAY') {