From 8f9d07513aa193942c3f9de6d6fc2aa1edb64d0d Mon Sep 17 00:00:00 2001 From: Jakob Haufe Date: Mon, 3 Jul 2017 10:09:01 +0000 Subject: [PATCH] Change mechanism for output file names - Write output to current working directory - Generate output PDF names based on meta file instead of origin PDF to allow for multiple stitch jobs per PDF --- gencropped | 2 +- genmeta | 5 +++-- genpreview | 2 +- pdfstitch | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gencropped b/gencropped index 1b99c2d..23af63a 100755 --- a/gencropped +++ b/gencropped @@ -28,5 +28,5 @@ foreach my $nr (@{$meta->{pageorder}}) $page->cropbox($llx, $lly, $urx, $ury); } -$cropped->saveas(basename($meta->{input}, '.pdf') . '-cropped.pdf'); +$cropped->saveas(basename($metafile, ('.pdf.stitch', '.stitch')) . '-cropped.pdf'); diff --git a/genmeta b/genmeta index ee534b6..c298894 100755 --- a/genmeta +++ b/genmeta @@ -2,6 +2,7 @@ use strict; +use File::Basename; use PDF::API2; use YAML; @@ -10,7 +11,7 @@ my $infile = $ARGV[0]; die "Please specify PDF to examine!\n" unless defined $infile; die "Could not open $infile!\n" unless -r $infile; -my $outfile = "${infile}.stitch"; +my $outfile = basename($infile) . ".stitch"; die "$outfile exists, aborting!\n" if -e $outfile; @@ -22,7 +23,7 @@ my $page = $pdf->openpage(1); my ($llx, $lly, $urx, $ury) = $page->get_mediabox; my $meta = { - input => $infile, + input => basename($infile), x => (($urx - $llx)*0.1)/2, y => (($ury - $lly)*0.1)/2, width => ($urx - $llx)*0.9, diff --git a/genpreview b/genpreview index 6cd9b8f..7526fe7 100755 --- a/genpreview +++ b/genpreview @@ -35,5 +35,5 @@ foreach my $nr (@{$meta->{pageorder}}) $content->fill(); } -$outpdf->saveas(basename($meta->{input}, '.pdf') . '-preview.pdf'); +$outpdf->saveas(basename($metafile, ('.pdf.stitch','.stitch')) . '-preview.pdf'); diff --git a/pdfstitch b/pdfstitch index 1794a8a..0608bc8 100755 --- a/pdfstitch +++ b/pdfstitch @@ -51,5 +51,5 @@ foreach my $nr (@{$meta->{pageorder}}) } -$outpdf->saveas(basename($meta->{input}, '.pdf') . '-stitched.pdf'); +$outpdf->saveas(basename($metafile, ('.pdf.stitch','.stitch')) . '-stitched.pdf'); -- 2.39.5