Subject: | addImgScaled |
Date: | Wed, 1 Apr 2009 09:34:30 +1100 |
To: | <bug-PDF-Report [...] rt.cpan.org> |
From: | "Adrian Lui" <ALui [...] civica.com.au> |
Dear Sir,
I have been using the perl module PDF::Report that you have written,
I must say it is a very good and useful module.
However, I find that the addImgScaled subroutine does not seems to
work as code lines are commented out as follows:
sub addImgScaled {
my ( $self, $file, $x, $y, $scale ) = @_;
# my $img = $self->{pdf}->image($file);
# my $gfx = $self->{page}->gfx;
# $gfx->image($img, $x, $y, $scale);
$self->addImg($file, $x, $y);
}
I am just wondering whether it would be nice to modify the addImg
subroutine to accept 2 more arguments for the width and height of the
image, that way, we can make the addImgScaled a function call to addImg
with passed parameters. I have highlighted the change I propose in red.
sub addImg {
my ( $self, $file, $x, $y, $w, $h ) = @_;
my %type = (jpeg => "jpeg",
jpg => "jpeg",
tif => "tiff",
tiff => "tiff",
pnm => "pnm",
gif => "gif",
png => "png",
);
$file =~ /\.(\w+)$/;
my $ext = $1;
my $sub = "image_$type{$ext}";
my $img = $self->{pdf}->$sub($file);
my $gfx = $self->{page}->gfx;
if (( $w > 0 ) && ( $h > 0 ))
{
$gfx->image($img, $x, $y, $w, $h);
}
else
{
$gfx->image($img, $x, $y);
}
}
sub addImgScaled {
my ( $self, $file, $x, $y, $scale ) = @_;
# my $img = $self->{pdf}->image($file);
# my $gfx = $self->{page}->gfx;
# $gfx->image($img, $x, $y, $scale);
my ($iw,$ih) = imgsize($file);
$self->addImg($file, $x, $y, ($iw*$scale), ($ih*$scale));
}
Thankyou for spending time reading my email.
Cheers,
Adrian
--
This email is from Civica Pty Limited and it, together with
any attachments, is confidential to the intended recipient(s)
and the contents may be legally privileged or contain
proprietary and private information. It is intended solely
for the person to whom it is addressed. If you are not an
intended recipient, you may not review, copy or distribute
this email. If received in error, please notify the sender
and delete the message from your system immediately. Any
views or opinions expressed in this email and any files
transmitted with it are those of the author only and may
not necessarily reflect the views of Civica and do not create
any legally binding rights or obligations whatsoever. Unless
otherwise pre-agreed by exchange of hard copy documents
signed by duly authorised representatives, contracts may not
be concluded on behalf of Civica by email. Please note that
neither Civica nor the sender accepts any responsibility for
any viruses and it is your responsibility to scan the email
and the attachments (if any). All email received and sent by
Civica may be monitored to protect the business interests of
Civica.