Dear Almut - Thank you very much for your reply. It has worked
I now have another question relating to the PDF::TextBlock module which can also be used to create nice paragraphs in PDFs
.Firstly I have altered the code of the TextBlock.pm module at line 376
# Don't yet know why we'd want to return @paragraphs... # unshift( @paragraphs, join( ' ', @paragraph ) ) if scalar(@paragr +aph); # return ( $endw, $ypos ); # , join( "\n", @paragraphs ) ) unshift( @paragraphs, join( ' ', @paragraph ) ) if scalar(@paragrap +h); my $overflow = join("\n",@paragraphs); return ( $endw, $ypos, $overflow); #$overflow text returned to s +cript
to return the overflowed text from TextBlock.pm to my script .This overflow text is then placed into a second block by my script
My entire script for this is :-
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 . "<b>This fairly lengthy</b>\n\n". 'rather verbose sentence <b>is tagged</b> to appear ' . 'in a <b>different font, specifically the one we tagged b for "bo +ld".</b> ' . $tb->garbledy_gook . ' <href="http://www.omnihotels.com">Click here to visit Omni Hote +ls.</href> ' . $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;
However the second block containing the overflow text is on a second page
I have 2 questions.
1. There is a method or reference in the TextBlock.pm file for specifing which page to put the block of text on but what do I need to type in my script to access this method and put all the text blocks on page 1 or 2 etc?
2. Would it be possible to alter the TextBlock.pm to change the colour of the text especially inside the 'markup' tags (so hyperlinks could appear blue or bold text appear red etc)? If this is not possible could one specify the colour of an entire text block
Thank you in advance for your help
In reply to Re^2: PDF::API2 Paragraphs and Overflow Text
by dickieb
in thread PDF::API2 Paragraphs and Overflow Text
by dickieb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |