10 die "Please specify PDF to examine!\n" unless defined $infile;
11 die "Could not open $infile!\n" unless -r $infile;
13 my $outfile = "${infile}.stitch";
15 die "$outfile exists, aborting!\n" if -e $outfile;
17 print 'Creating metafile for '.$infile."...\n";
19 my $pdf = PDF::API2->open($infile);
21 my $page = $pdf->openpage(1);
22 my ($llx, $lly, $urx, $ury) = $page->get_mediabox;
26 x => (($urx - $llx)*0.1)/2,
27 y => (($ury - $lly)*0.1)/2,
28 width => ($urx - $llx)*0.9,
29 height => ($ury - $lly)*0.9,
30 columns => int(sqrt($pdf->pages)),
31 rows => int(sqrt($pdf->pages)),
32 pageorder => [(1 .. $pdf->pages)],
35 foreach $page (1..$pdf->pages)
37 $meta->{pageoffsets}->{$page}->{x} = 0;
38 $meta->{pageoffsets}->{$page}->{y} = 0;
41 YAML::Bless($meta)->keys(['input','x','y','width','height','columns','rows', 'pageorder','pageoffsets']);
42 YAML::DumpFile($outfile,$meta);