Hi,

Please find below the sample code snippet, that I am trying to run

,
#!/usr/bin/perl -w use strict; use warnings; use PDF::API2; use PDF::Table; use PDF::Report; #$font_dir = '/usr/share/fonts/opentype'; #PDF::API2::addFontDirs($font_dir); my $pdf = PDF::API2->new( -file => "test.pdf" ); my $page = $pdf->page; $pdf->mediabox('A4'); $page->rotate(90); $pdf->info( 'Author' => 'Test1', 'Title' => 'Test_Demo', ); my $f3 = $pdf->ttfont('TrajanPro-Bold.otf', -encoding=>'latin1'); my %font = ( Helvetica => { Bold => $pdf->corefont( 'Helvetica-Bold', -encoding => 'l +atin1' ), Roman => $pdf->corefont( 'Helvetica', -encoding => 'l +atin1' ), Italic => $pdf->corefont( 'Helvetica-Oblique', -encoding => 'l +atin1' ), }, Times => { Bold => $pdf->corefont( 'Times-Bold', -encoding => 'latin1 +' ), Roman => $pdf->corefont( 'Times', -encoding => 'latin1 +' ), Italic => $pdf->corefont( 'Times-Italic', -encoding => 'latin1 +' ), }, Arial => { Bold => $pdf->corefont( 'Arial-Bold', -encoding => 'latin +1' ), Roman => $pdf->corefont( 'Arial', -encoding => 'latin +1' ), Italic => $pdf->corefont( 'Arial-Italic', -encoding => 'latin1 +' ), }, ); #$f2=$pdf->corefont('Times',-encode=>'latin1'); my $f2 = $pdf->ttfont('MyriadPro-BoldSemiCn.otf'); my $red_box = $page->gfx; $red_box->fillcolor('darkred'); $red_box->rect( 5, 720, 605, 5 ); $red_box->fill; my $red_box2 = $page->gfx; $red_box2->fillcolor('darkred'); $red_box2->rect( 5, 640, 605, 2 ); $red_box2->fill; #my $page2 = $pdf->page; my $pdftable1 = new PDF::Table; my $table1_data = [['testvalue', 'test', 'test executed' ,'Executed te +st value','Average value (millions)', 'Average completion time (hrs.) +', 'Average participation rate' , ' Average start time' , 'Average en +d time' ,' Short term volatility', 'Historical volatility' ], ['test','1','1','2','1','2','3','5','6','7'],]; $pdftable1->table( $pdf, $page, $table1_data, x => 5, -w => 700, start_y => 622, next_y => 500, -start_h => 200, next_h => 500, # some optional params -padding => 3, font_size => 10, border => 0, # padding_right => 10, background_color_odd => 'lightblue', background_color_even => "white", #cell background color for +even rows new_page_func => sub { my $next_page = $pdf->page; $next_page->rotate(90); return $next_page; }, header_props => { bg_color => "white", font => $f2, font_size => 10, font_color => "black", repeat => 1, }, column_props => [ {}, { min_w => 30, justify => "center", font => $pdf->corefont("Arial", -encoding => "utf8"), font_size => 10, font_color=> 'black', #background_color => '#8CA6C5', }, ], cell_props => [ [#This is the first(header) row of the table and here wins +header_props { # background_color => '#000000', font_size => 8, font_color => 'black', }, # etc. ], [#Row 2 {#Row 2 cell 1 #background_color => '#000000', font_color => 'black', }, {#Row 2 cell 2 #background_color => '#AAAA00', font_color => 'black', }, {#Row 2 cell 3 #background_color => '#FFFFFF', font_color => 'green', }, # etc. ], [#Row 3 {#Row 3 cell 1 #background_color => '#AAAAAA', font_color => 'blue', }, # etc. ], # etc. ], ); $pdf->save;

Please let me know if you need ay other information.

Thanks

In reply to Re^6: Table in landscape view with PDF::API2 and PDF::Table by manua
in thread Table in landscape view with PDF::API2 and PDF::Table by manua

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.