in reply to Re^3: Table in landscape view with PDF::API2 and PDF::Table
in thread Table in landscape view with PDF::API2 and PDF::Table

I have created a page with PDF::API2 and have rotated that page by 90. I want to draw my table in hte landscape view on this page. But in actual, when I rotate the page the axis of page remains same and the table is created in the potrait form only. I want that with the change in page orientation the axes of the page should also change and accordingly the table and other stuff, should teke the new/modified coordinates.
  • Comment on Re^4: Table in landscape view with PDF::API2 and PDF::Table

Replies are listed 'Best First'.
Re^5: Table in landscape view with PDF::API2 and PDF::Table
by Corion (Patriarch) on Feb 15, 2010 at 16:24 UTC

    You don't show any code that I could run. How do you expect me to identify potential problems in your program?

      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

        I am able to resolve the issue by defining the mediabox as landscape and drawing th table within that.

        Thanks

        Manu