For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > May 2004 > PDF::API2::Text::font fix.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author PDF::API2::Text::font fix.
psyshrike

2004-05-12, 7:21 pm

Howdy,

Not sure what email address to send this to, so I'll post it here.

If somebody could add this or something like it to the
PDF::API2::Text::font function in the PDF::API2 Distro it would be
usefull to many IMHO.

All I added was the hail mary to get the font size.

Basically:
$txt->font($small, 20) ;
Can be stated as:
$txt->font($small) ;

if the font contained in $small already knows what size it is. This
makes managing your fonts a little cleaner.

The replacement function:
##########################

sub font {
my ($self,$font,$size)=@_;

if (! defined $size &&
! ref($font->{"PDFAPIOptions"}->{"val"}) &&
$font->{"PDFAPIOptions"}->{"val"} =~ /[0-9]+/) {
$size = $font->{"PDFAPIOptions"}->{"val"} ;
}

$self->{' font'}=$font ;
$self->{' fontsize'}=$size;
$self->add("/".$font->{' apiname'},float($size),'Tf');

$self->resource('Font',$font->{' apiname'},$font);

return($self);
}

-Thanks!
-Matt
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com