Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PDF::CREATE

Status
Not open for further replies.

mrortner

IS-IT--Management
Jun 22, 2001
38
0
0
US
Anyone know how to start a new page after 20 lines pulling from a database using PDF::CREATE.
Here is what I have so far.
This prints heading on both pages and the line on both pages then prints all the output on the first page or second page which ever I specify $first to be. So the first page prints then the contents of the 2nd page prints on top of the print of the first page.



sub pdf_matrix
{
#use this to get max length of record. max(lenght(field))
BEGIN { unshift @INC, "lib", "../lib" }
($SQL) = @_;
$head1 = 'Year'; $head2 = 'Month'; $head3 = 'Original'; $head33 = 'Request';
$head4 = 'Modified'; $head5 = 'Re-run'; $head6 = 'Total';

my $dbh = DBI->connect('dbi:DB2:DB2P',&quot;$mf_id&quot; , &quot;$mf_pw&quot;); if ($DBI::errstr) {print &quot;<CENTER><B> $DBI::errstr </B></CENTER> &quot;;}
my $sth = $dbh->prepare($SQL); if ($DBI::errstr) {print &quot;$DBI::errstr&quot;;}
my $rc = $sth->execute; if ($DBI::errstr) {print &quot;$DBI::errstr&quot;;}


my $pdf = new PDF::Create('filename' => 'D:/DWH_WEB/' . $file1,
'Version' => 1.2,
'PageMode' => 'UseOutlines',
'Author' => 'Fabien Tassin',
'Title' => 'My title',
);
my $root = $pdf->new_page('MediaBox' => [ 0, 0, 612, 792 ]);

# Add a page which inherits its attributes from $root


# Prepare 2 fonts
my $f1 = $pdf->font('Subtype' => 'Type1',
'Encoding' => 'WinAnsiEncoding',
'BaseFont' => 'Helvetica');
my $f2 = $pdf->font('Subtype' => 'Type1',
'Encoding' => 'WinAnsiEncoding',
'BaseFont' => 'Helvetica-Bold');

# Prepare a Table of Content
my $toc = $pdf->new_outline('Title' => 'Document',
'Destination' => $page);
$toc->new_outline('Title' => 'Section 1');
my $page = $root->new_page;

$page->stringc($f2, 20, 306, 775, &quot;Info Center Reports&quot;);
$page->stringc($f2, 15, 306, 755, &quot;Date Range&quot;);
$page->stringc($f2, 15, 306, 735, $SDATE .&quot; and &quot;. $EDATE);
$page->stringc($f2, 12, 101, 680, $head1);
$page->stringc($f2, 12, 183, 680, $head2);
$page->stringc($f2, 12, 265, 690, $head3);
$page->stringc($f2, 12, 347, 690, $head4);
$page->stringc($f2, 12, 429, 690, $head5);
$page->stringc($f2, 12, 511, 680, $head6);
$page->stringc($f2, 12, 265, 670, $head33);
$page->stringc($f2, 12, 347, 670, $head33);
$page->stringc($f2, 12, 429, 670, $head33);
$page->line (10,650, 600, 650);

# Add another page

my $page2 = $root->new_page;


$page2->stringc($f2, 20, 306, 775, &quot;Info Center Reports&quot;);
$page2->stringc($f1, 15, 306, 755, &quot;Date Range&quot;);
$page2->stringc($f1, 15, 306, 735, $SDATE .&quot; and &quot;. $EDATE);
$page2->stringc($f2, 12, 101, 680, $head1);
$page2->stringc($f2, 12, 183, 680, $head2);
$page2->stringc($f2, 12, 265, 690, $head3);
$page2->stringc($f2, 12, 347, 690, $head4);
$page2->stringc($f2, 12, 429, 690, $head5);
$page2->stringc($f2, 12, 511, 680, $head6);
$page2->stringc($f2, 12, 265, 670, $head33);
$page2->stringc($f2, 12, 347, 670, $head33);
$page2->stringc($f2, 12, 429, 670, $head33);
$page2->line (10,650, 600, 650);

# Add something to the first page
$line = 630;
$line1 = 630;
$line2 = 293;
# $col = 306;
$varlen1 = 1;
$first =$page;
while (($a1, $a2, $a3, $a4, $a5, $a6, $a7) = $sth->fetchrow())
{


#if ($varlen1 < length($a1)){$varlen1 = length($a1)}
#if ($varlen2 < length($a3)){$varlen2 = length($a3)}
#if ($varlen3 < length($a4)){$varlen3 = length($a4)}
#if ($varlen4 < length($a5)){$varlen4 = length($a5)}
#if ($varlen5 < length($a6)){$varlen5 = length($a6)}
#if ($varlen6 < length($a7)){$varlen6 = length($a7)}
#
#if ($varlen3 > length($head3)){$collength1 = $col - $varlen3 - 35;}else{$collength1 = $col - length($head3) - 35;}
#if ($varlen2 > length($head2)){$collength2 = $collength1 - $varlen2 - 70;}else{$collength2 = $collength1 - length($head2) - 70;}
#if ($varlen1 > length($head1)){$collength3 = $collength2 - $varlen1 - 70;}else{$collength3 = $collength2 - length($head1) - 70;}
# Add another page

$first->stringc($f1, 12,101, $line, $a1);
$first->stringc($f1, 12,183, $line, $a3);
$first->stringc($f2, 12,265, $line, $a4);
$first->stringc($f2, 12,347, $line, $a5);
$first->stringc($f1, 12,429, $line, $a6);
$first->stringc($f1, 12,511, $line, $a7);



$line = $line-20;
$line--;

if ($line < 550 ){$first = $page2; $line = 630; }


}
 
Does anyone have a better module suggestion to do what I am looking to do?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top