Posted on 2008-10-08 17:47:41-07 by kherge
Background color in textlabel()?
I took a quick look at the textlabel() method in the documentation and I see no where that setting the background color of the text label is allowed. What I'm trying to do is overlay a date on top of an existing one in the PDF. Since the date format can vary, locating the element and removing it seems like not the best approach. Is this possible at all? Am I using the wrong approach? Here's some of the code that I'm using:
my $pdf = PDF::API2->open( $file ); my $page = $pdf->openpage( 1 ); my $font = $pdf->corefont( "Arial" ); my $dlab = $page->gfx; # Set date. $dlab->textlabel( 161, 84, $font, 7, $date->month_name . " " . $date->day . ", " . $date->year, -align => 'right' );
Direct Responses: 9005 | Write a response
Posted on 2008-10-09 07:08:46-07 by teotwawki in response to 8998
Re: Background color in textlabel()?
You could add a rectangle of white over the unwanted area before adding your new text:
$gfx->strokecolor('white'); $gfx->fillcolor('white'); $gfx->linewidth(0); $gfx->rectxy(161, 84, 161+(72*18/10), 84+7); # above assumes longest previous date is 18 chars at 10cpi $gfx->fillstroke();
I would also recommend adding the new date in the ISO8601 format to avoid confusion, particularly if the documents will have readers throughout the world.
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.