in reply to Text to PDF

PDF::API2 is packaged by Active State.

This works :
use strict; use warnings; use PDF::API2; # Create a pdf object. my $pdf = PDF::API2->new(-file => "test.pdf"); # Create a media box in pdf object. $pdf->mediabox(595,842); # Create font objects. my $fnt = $pdf->corefont('Verdana',-encode => 'latin1'); my $boldfont=$pdf->corefont('Verdana-Bold',-encode => 'latin1'); # Set the font size. my $font_size=8; # Create a page object. my $page = $pdf->page(0); # Create a text object on the page. my $txt = $page->text; $txt->font($boldfont,$font_size); $txt->translate(20,800); $txt->text("A Heading here."); $txt->font($fnt, $font_size); $txt->translate(100,750); $txt->font($fnt, $font_size); $txt->text("A small piece of text here."); # Read a large piece of text from a file and put it in a paragraph on +the PDF document. open(FH, "<largetext.txt") or die "$!\n"; my @fred=<FH>; close FH; $txt->paragraph(join("\n", @fred), -x=>30, -y=>720, -w=>500, -h=>800); # Save the PDF and destroy the object. $pdf->save; $pdf->end( );
...but it has a few problems. It requires that you know (or calculate) the size of the paragraph, and it seems to ignore some formatting, such as multiple spaces and newlines. It also requires that you put your own page breaks in. With a bit of work, it could be made to do what you want.

Replies are listed 'Best First'.
Re^2: Text to PDF
by drodinthe559 (Monk) on Jan 29, 2010 at 17:09 UTC
    I'll check it out. Thanks for the info, Dave