use PDF::API2;
use PDF::TextBlock;
my $pdf = PDF::API2->new( -file => "/home/mytest.pdf" );
my $tb = PDF::TextBlock->new({
pdf => $pdf,
x => 120,
y => 350,
w => 350,
h => 300,
fonts => {
b => PDF::TextBlock::Font->new({
pdf => $pdf,
font => $pdf->corefont( 'Helvetica-Bold', -encoding => 'latin1' ),
}),
},
});
$tb->text(
$tb->garbledy_gook .
"This fairly lengthy\n\n".
'rather verbose sentence is tagged to appear ' .
'in a different font, specifically the one we tagged b for "bold". ' .
$tb->garbledy_gook .
' Click here to visit Omni Hotels. ' .
$tb->garbledy_gook . "\n\n" .
"New paragraph.\n\n" .
"Another paragraph."
);
#Get return values from altered TextBlock.pm
($endw,$ypos,$overflow)=$tb->apply;
$overflow="Overflow text is :- $overflow";
#Now place the overflow text in a new text block
my $tb = PDF::TextBlock->new({
pdf => $pdf,
x => 120,
y => 260,
w => 250,
h => 50,
fonts => {
b => PDF::TextBlock::Font->new({
pdf => $pdf,
font => $pdf->corefont( 'Helvetica-Bold', -encoding => 'latin1' ),
}),
},
});
$tb->text("$overflow");
$tb->apply;
$pdf->save;