use strict; use DBI; use MoosePdf; my $pdf = new MoosePdf('myPdf.pdf'); my $page = $pdf->addPage(size=>'595x852', margins=> 72); my $f = $page->addFont("Helvetica"); my $fb = $page->addFont("Helvetica-Bold"); my $image = $page->addImage(file=>"santa.jpg"); #path my $height = $image->getHeight; $page->showImage( image=>$image, x=>100, y=> 100+$height); $page->addText( text=>"Heading Here", x=>100, y=>100, font=>$fb, size=> 10 ); my $dbh=DBI->connect("DBI:mysql:database=voice:host=localhost","username","password") or die "$!\n"; my $sth=$dbh->prepare("select column1,column2,column3,column4,column5 from test") or die "$!\n"; $sth->execute() or die "$!\n"; my $y = 750; while (my @row=$sth->fetchrow_array()) { $y -= 45; my $string=join(",",@row)."\n"; $page->addText( text=>$string, x=>100, y=>$y, font=>$f, size=> 10 ); if( $y < 100 ){ $page = $pdf->AddPage(); #inherits from existing page $page->addText(text=>"Heading Here", font=>$fb, size=>10, x=>100, y=>800 ); $y = 750; } } $pdf->save();