G'day Dermot,
Why bother with all the rotation stuff? Why not just make a landscape
document?
I believe the following script will suit your purposes (unless I've
misunderstood them)
For those interested in PDF::API2, but frustrated by the lack of
documentation, I have a tutorial (that Dermot has read) available at
http://www.printaform.com.au/clients/pdfapi2/ (.. and yes, I know
there's a broken link)
Cheers!
Rick Measham
#!/bin/perl
use PDF::API2;
use Image::Magick;
use strict;
use warnings;
# These mean it's much easier to work with dimensions as 5mm can be
written 5/mm
use constant pt => 1;
use constant mm => 25.4/72;
# Create a new PDF object;
my $pdf = PDF::API2->new(-file => "mypdf.pdf");
$pdf->preferences(
-singlepage => 1,
-thumbs => 1,
-fith => 1,
);
# ========== Create the first page.=====
my $page = $pdf->page;
# === specify media (page) size
# Crop size needs to specified as slightly less then media
# or your'll get ink on the rollers.
$page->mediabox(297/mm, 210/mm);
$page->cropbox( 5/mm, 5/mm, 287/mm, 200/mm);
# Start the X & Y coordinates for the page.
# coordinates are given from the bottom left corner.
my $y = 5/mm;
my $x = 5/mm;
# ===== Scale =====
# specify the scaling here as it is dotted around the program.
my $scale = .72;
# my $no = @ref;
my $no = 12;
my $maxheight = 0;
for (my $i = 0; $i < $no; ++$i ) {
if ($i and $i % 8 == 0) {
$page = $pdf->page;
$page->mediabox(297/mm, 210/mm);
$page->cropbox( 5/mm, 5/mm, 287/mm, 200/mm);
}
if ($i and $i % 4 == 0) {
$x = 5/mm;
$y = $maxheight + 5/mm;
$maxheight = 0;
}
my $photo = $page->gfx;
my $img_file = 'test.jpg';
unless (-e $img_file) {
warn("Unable to find image $img_file: $!\n");
next;
}
my ($img_width, $img_height, $size, $format) =
Image::Magick->new->Ping($img_file);
my $jpeg = $pdf->image_jpeg($img_file);
$photo->image($jpeg,$x,$y,$scale);
print "inserting $img_file at x=$x, y=$y\n";
$x += $img_width + 5/mm;
$maxheight = $img_height if $img_height > $maxheight;
}
$pdf->save;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>