Hi Monks!
I am going crazy here trying to create dynamic pdf pages out of a database query, so far I can get the results from my database into the pdf-s OK, but I need to make sure that all the pdf pages are created in landscape mode, the table will be to big to fit otherwise, and the code I have so far only flips the first page correctly, I've tried everything like, "$page->rotate(90); #landscape", and no success. Also if anyone has worked on this stuff before and know if it is possible to add a link to one of the values returned from the database would be even more helpful for me.
Here is the code I am working on:
use strict;
use CGI qw(:header);
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;
use DBI;
use PDF::API2;
use PDF::Table;
print header();
my $pdftable = new PDF::Table;
my $pdf = new PDF::API2( -file => "pdf_table.pdf"
);
$pdf->preferences(
-singlepage => 1,
-thumbs => 1,
-fith => 1,
);
my $page = $pdf->page;
$page->mediabox(792,612);
#*Connect with sql dbonce:::
my $db = "LocalServer";
#...
my $sql = "SELECT DISTINCT name, email ,phone, city, state
FROM details LEFT OUTER JOIN main ON details.name = main.na
+me
";
my $sth = $dbh->prepare($sql)|| die $dbh->errstr;
$sth->execute() or die "$!\n";
my $array_ref = $sth->fetchall_arrayref();
my $c=0;
my $rows=750;
my $left_edge_of_table = 10;
$pdftable->table(
# required params
$pdf,
$page,
\@{$array_ref},
x => $left_edge_of_table,
w => 495, # width of table
start_y => 590, # top of page
next_y => 800, # top of all other pages
start_h => 500, # rows per page
next_h => 500, # rows per page on all other pages
# optional params
padding => 5,
padding_right => 10,
background_color_odd => "gray",
background_color_even => "lightblue", #cell background color for
+even rows
);
$pdf->saveas();
Thank you very much!!!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.