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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.