However, this puts the image on top of the text, and the text becomes unreadable. I need to be able to read the text. Given that I don't really understand the way PDFs work, can anybody point me in the right direction?use strict; use warnings; use DBI; use DBD::mysql; use PDF::API2; my $font_size=10; my $pdf = PDF::API2->new(-file => "mypdf.pdf"); $pdf->mediabox(595,842); my $page = $pdf->page; my $fnt = $pdf->corefont('Helvetica',-encode => 'latin1'); my $boldfont=$pdf->corefont('Helvetica-Bold',-encode => 'latin1'); my $txt = $page->hybrid; my $gfx=$page->gfx; $txt->textstart; $txt->font($boldfont,$font_size); $txt->translate(100,800); $txt->text("Heading here."); my $image=$pdf->image_jpeg('santa.jpg'); $gfx->image( $image, 100, 100 ); $txt->font($fnt, $font_size); $txt->translate(100,750); my $y=750; $txt->font($fnt, $font_size); my $dbh=DBI->connect("DBI:mysql:database=voice:host=localhost","userna +me","password") or die "$!\n"; my $sth=$dbh->prepare("select column1,column2,column3,column4,column5 +from test") or die "$!\n"; $sth->execute() or die "$!\n"; while (my @row=$sth->fetchrow_array()) { my $string=join(",",@row)."\n"; $txt->translate(100,$y); $txt->text("$string"); $y-=45; if ($y < 100 ) { $txt->textend; $page = $pdf->page(0); $txt = $page->hybrid; $txt->textstart; $txt->font($fnt, $font_size); $txt->translate(100,800); $y=750; $txt->textstart; $txt->font($boldfont,$font_size); $txt->text("Heading here."); $txt->font($fnt, $font_size); } } $sth->finish(); $dbh->disconnect(); $txt->textend; $pdf->save; $pdf->end( );
In reply to Putting text and images in PDFs using PDF::API2 by leighsharpe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |