9 my $metafile = $ARGV[0];
11 die "Please specify a .pdf.stitch to process!\n" unless defined $metafile;
12 die "Can't open $metafile!\n" unless -r $metafile;
14 my $meta = YAML::LoadFile($metafile);
16 my $inpdf = PDF::API2->open($meta->{input});
17 my $cropped = PDF::API2->new();
19 foreach my $nr (@{$meta->{pageorder}})
21 print "Cropping page $nr...\n";
22 my $page = $cropped->import_page($inpdf, $nr, 0);
23 my ($llx, $lly, $urx, $ury);
24 $llx = $meta->{x} + $meta->{pageoffsets}->{$nr}->{x};
25 $lly = $meta->{y} + $meta->{pageoffsets}->{$nr}->{y};
26 $urx = $llx + $meta->{width};
27 $ury = $lly + $meta->{height};
28 $page->cropbox($llx, $lly, $urx, $ury);
31 $cropped->saveas(basename($metafile, ('.pdf.stitch', '.stitch')) . '-cropped.pdf');