leighsharpe has asked for the wisdom of the Perl Monks concerning the following question:
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( );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Putting text and images in PDFs using PDF::API2
by jbrugger (Parson) on Jan 17, 2006 at 10:01 UTC | |
by JamesNC (Chaplain) on Jan 17, 2006 at 13:22 UTC | |
by Anonymous Monk on Mar 27, 2009 at 14:08 UTC | |
|
Re: Putting text and images in PDFs using PDF::API2
by chargrill (Parson) on Jan 17, 2006 at 07:27 UTC | |
by JamesNC (Chaplain) on Jan 17, 2006 at 07:53 UTC | |
by leighsharpe (Monk) on Jan 18, 2006 at 01:41 UTC | |
|
Re: Putting text and images in PDFs using PDF::API2
by RandomWalk (Beadle) on Dec 23, 2007 at 19:46 UTC | |
by edoc (Chaplain) on Nov 08, 2011 at 01:36 UTC | |
by larrymcp (Novice) on Dec 21, 2015 at 02:02 UTC |