#!perl
use strict;
use warnings;
use PDF::API2;
my $save_pdf_as = "mypdf.pdf";
my $pdf = PDF::API2->new();
my $page = $pdf->page()
->mediabox('Letter');
my $font = $pdf->corefont('Helvetica-Bold');
my $text = $page->text()
->font($font, 20);
$text->lead(25);
$text->translate(100, 700);
while (<DATA>){
$text->paragraph($_, 400, 400, -align => "left" ); # width height
$text->cr(-5);
}
$pdf->saveas($save_pdf_as);
__DATA__
line 1 is a very long line that extends past the end of the page
line 2 is also very long line that extends past the end of the page
line 3
line 4
The height of the paragraph box needs to be large enough for the text
If you need to spread the text across multiple pages then it can get complicated !
poj |