I know that PDF::API2 has the "rotate" and "translate", but am I right in thinking this applies to the whole page content?

What I am TRYING to do is arrange 16x A4 prints into an A0 PDF. I THOUGHT I could load an image, rotate it, and move it to X/Y co-ordinates, using a loop to move across and up. The images are created at 300DPI, so the inches dimensions when divided by 72 come out at around 595 x 842 (portrait mode when rotated)

I also thought that the bottom left corner once rotated would be 595 to the right of the true PDF 0,0 co-ordintates of bottom left of PDF.

Alas, at present, it appears to be adding a photo, rotating page, adding another, rotating page and so on. So its not moving up the page as expected either.

Have I got to rotate my original images, and then just use co-ordinates to place? Or is there a potential workaround?

my $dir='../../wordboards/standard'; opendir my $dh, $dir or die "Could not open '$dir' for reading '$!'\n" +; my @pics = readdir $dh; closedir $dh; shift @pics; shift @pics; my $pdf = PDF::API2->new(); # Set the page size my $page = $pdf->page(); $page->mediabox('A0'); #Each A4 is 841 x 595 my $content = $page->gfx; for (my $row=0; $row<4; $row++){ for (my $col=0; $col<4; $col++){ my $count=($row*4)+$col; my $photoFile = $pdf->image_jpeg($dir."/".$pics[$count]); $content->image($photoFile, 0, 0); $content->transform( -translate => [my $_x = 595+($row*595), my $_y = ($col*8 +42)], # Top left is 0,0 when rotated (ie bottom left is 842 points + to right) -rotate => 90, ); } }

Since an image is usually placed bottom left to top left, once rotated 90 degrees, my theory is that it would be printed in columns of data running right to left, hence moving start co-ordinates to the right


In reply to Making a 4 x 4 of rotated images (PDF::API2) by cristofayre

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.