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