Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: PDF::Table seems to ignore column properties when there are but two columns

by ted.byers (Scribe)
on Jul 10, 2013 at 14:56 UTC ( #1043483=note: print w/ replies, xml ) Need Help??


in reply to Re^2: PDF::Table seems to ignore column properties when there are but two columns
in thread PDF::Table seems to ignore column properties when there are but two columns

As promised, here is a sample that shows exactly what I am seeing:

use strict; use warnings; use PDF::API2; use PDF::Table; my $pdf = new PDF::API2(-file => 'test5.pdf'); my $page = $pdf->page; # Table data, two columns my $table_data1 = [ [ 'balance forward', '$ 0.00' ], [ 'credit', '$ 100.00' ], [ 'debit', '$ 200.00'], [ 'balance', '$ 100.00' ], ]; my $table_data2 = [ [ 'balance forward', '$ 0.00' ], [ 'credit', '$ 10.00' ], [ 'debit', '$ 20.00'], [ 'balance', '$ 10.00' ], ]; my $table_data3 = [ [ 'balance forward', '$ 0.00' ], [ 'credit', '$ 100,000.00' ], [ 'debit', '$ 200,000.00'], [ 'balance', '$ 100,000.00' ], ]; my $table_data4 = [ [ 'balance forward', '$ 0.00' ], [ 'credit', '$ 1.00' ], [ 'debit', '$ 2.00'], [ 'balance balance balance balance', '$ 1.00' ], ]; my $col_props = [ { font => $pdf->corefont("Courier-Bold"), width => 250, font_color => 'blue', },{ font => $pdf->corefont("Courier-Bold"), width => 50, justify => 'right', font_color => 'green', } ]; my $pdftable1 = new PDF::Table; my ($end_page, $pages_spanned, $table_bot_y) = $pdftable1->table($pdf, + $page, $table_data1, -column_props => $col_props, -w => 300, -start_y => 750, -start_h => 300, -padding => 10, -x => 50, ); $table_bot_y -= 5; my $pdftable2 = new PDF::Table; ($end_page, $pages_spanned, $table_bot_y) = $pdftable1->table($pdf, $p +age, $table_data2, -column_props => $col_props, -w => 300, -start_y => $table_bot_y, -start_h => 300, -padding => 10, -x => 50, ); $table_bot_y -= 5; my $pdftable3 = new PDF::Table; ($end_page, $pages_spanned, $table_bot_y) = $pdftable1->table($pdf, $p +age, $table_data3, -column_props => $col_props, -w => 300, -start_y => $table_bot_y, -start_h => 300, -padding => 10, -x => 50, ); my $pdftable4 = new PDF::Table; $table_bot_y -= 5; $pdftable1->table($pdf, $page, $table_data4, -column_props => $col_props, -w => 300, -start_y => $table_bot_y, -start_h => 300, -padding => 5, -x => 50, ); $pdf->saveas();

What you will see is that the third table gets a right column that is bigger than the rest, and then the fourth gets a right column that is narrower than the rest. What is required is that the table actually respect the properties specified in col_props, so that I can adjust the width of the right column so that it will always accomodate the largest currency value I know exists in my data, and use that in all tables using a given col_props variable.

But I did notice that if I use a single instance of 'balance' in the fourth table, the table uses what looks like the same widths as those in the third table. Does the function 'table' actually modify col_props in those cases when it has the temerity to over-ride the values I coded? If so, what can be done about that?

Thanks

Ted


Comment on Re^3: PDF::Table seems to ignore column properties when there are but two columns
Download Code
Re^4: PDF::Table seems to ignore column properties when there are but two columns
by poj (Priest) on Jul 10, 2013 at 18:11 UTC
    Try using
    min_w => 250, max_w => 250,
    poj

      Thanks

      Alas, that didn't help.

      Are there any other options?

      Thanks

      Ted

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043483]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2015-07-03 03:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (48 votes), past polls