Subject: | Image rotation has a strange effect on its position |
Date: | Thu, 23 Apr 2020 10:08:47 +0200 |
To: | bug-PDF-API2 [...] rt.cpan.org |
From: | Fernando Santagata <nando.santagata [...] gmail.com> |
Hi,
When I first tried to rotate an image using $gfx->rotate(90); I found out
that the image was not visible on the page anymore.
After a series of attempts I found out that in order to make the image
appear on the page I needed to place it outside the visible page, i.e. when
I issue the
$gfx->image call I have to pass a negative starting x position.
I tried this on several images, with the same result.
This is the program I'm running:
use PDF::API2;
my ($output, $file) = @ARGV;
my $pdf = PDF::API2->new(-file => $output);
my $page = $pdf->page;
$page->mediabox('A4');
my $gfx=$page->gfx;
$image = $pdf->image_jpeg($file);
my $ratio = $image->width / $image->height;
my $x1 = 50;
my $y1 = -500; # position out of page
my $xlen = int(400 * $ratio);
my $x2 = $x1 + $xlen;
my $y2 = 400;
$gfx->rotate(90);
$gfx->image($image, $x1, $y1, $x2, $y2);
$gfx->close;
$gfx->stroke;
$pdf->update;
$pdf->end;
The program works perfectly, it's just that it sounds wrong to have to
position the image out of the page.
Is there anything I'm missing?
I'm using PDF::API2 v2.037 perl v5.30.0 on a Debian sid.
Thank you
--
Fernando Santagata