u671296 has asked for the wisdom of the Perl Monks concerning the following question:
use PDF::CreateSimple; use strict; use warnings; my $filename = "./test"; my $string = "hello there. This is a fairly long line containing lots +of utterly meaningless long-winded text that I would really realy rea +lly like to see wrapping onto the line below rather than just disapp +earing off the edge of the page.\nThis is still more on a second line +"; my $font_size=10; my $pdf = PDF::API2->new(-file => "mypdf.pdf"); my $page = $pdf->page; my $fnt = $pdf->corefont('Helvetica',-encode => 'latin1'); my $boldfont=$pdf->corefont('Helvetica-Bold',-encode => 'latin1'); my $txt = $page->text; #Heading needs to be centralised $txt->textstart; $txt->font($boldfont,$font_size); $txt->translate(100,770); $txt->text("Heading here."); $txt->textend; =pod #commented out graphic code $pdf->mediabox(595,842); my $gfx=$page->gfx; my $image=$pdf->image_jpeg('./logo.gif'); $gfx->image( $image, 100, 100 ); =cut #String does appear but incorrectly formatted $txt->textstart; $txt->font($fnt, $font_size); $txt->translate(50,670); $txt->text("$string"); $txt->textend; $pdf->save; $pdf->end( ); #------------------------------------------------------ # Try it with PDF::CreateSimple #------------------------------------------------------ my $pdfFile = PDF::CreateSimple->new("./pdfcs.pdf"); $pdfFile->drawText("$string",'Verdana',12,200,760,'black'); $pdfFile->drawImage('./logo.gif',150,650,1.75); $pdfFile->closeFile;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: PDF::API2 and PDF::CreateSimple
by MidLifeXis (Monsignor) on Feb 20, 2009 at 15:22 UTC | |
by u671296 (Sexton) on Feb 20, 2009 at 15:34 UTC | |
|
Re: PDF::API2 and PDF::CreateSimple
by mr_mischief (Monsignor) on Feb 20, 2009 at 16:07 UTC | |
by u671296 (Sexton) on Feb 20, 2009 at 16:25 UTC |