Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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?



In reply to Re^3: PDF::Table seems to ignore column properties when there are but two columns by ted.byers
in thread PDF::Table seems to ignore column properties when there are but two columns by ted.byers

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    [stevieb]: james28909: what's the problem/question?
    [james28909]: it is not an absolute date like "27" or "31". sometimes it is like wednesday or friday
    [james28909]: and i need to format those special instances into an absolute date instead of "yesterday"
    [stevieb]: ask a question on SoPW, and include at least a half-dozen examples of the input, and at least one example of expected output
    [davido]: Exactly: SoPW. This isn't going to be solved easily in the CB.
    [james28909]: in need "yesterday" and so on, to be absolute like "1" or "31"
    [stevieb]: ...and throw some of your existing code into the equation as well, just so readers know you've given a try at it ;)
    [james28909]: ok
    [stevieb]: davido thanks for the link ;) I was being the typical lazy
    [davido]: date parsing is hard. The more examples you can provide of the input (within reason) and expected output, the better.

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (4)
    As of 2017-04-29 02:36 GMT
    Find Nodes?
      Voting Booth?
      I'm a fool:

      Results (531 votes). Check out past polls.