diff options
author | Guilhem Moulin <guilhem.moulin@chalmers.se> | 2010-09-22 00:57:26 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem.moulin@chalmers.se> | 2010-09-22 00:57:26 +0200 |
commit | 4eab173014a1d0a6029e55acb7ad672ea201e622 (patch) | |
tree | 64803572aa1ecad9e19fb7e16abb8033e529ab8d | |
parent | f53231fdd4bb343d19026fe08817bff46341ae88 (diff) |
Viewer
-rwxr-xr-x | pdftool.pl | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -9,11 +9,13 @@ Getopt::Long::Configure ("bundling"); my $remote = 'graal'; my $pdf2ps = 'pdftops'; -my $ps2pdf = 'ps2pdf'; my $pscrop = 'psnup2.pl -s1 -l1'; +my $psresize = 'psresize'; my $psnup = 'psnup'; my $psbook = 'psbook'; +my $ps2pdf = 'ps2pdf'; my ($zip,$zcat) = ('bzip2','bzcat'); +my $pdfviewer = 'xpdf'; open(PAPERSIZE, "/etc/papersize") or die "Can't open `/etc/papersize'"; @@ -36,6 +38,7 @@ GetOptions( "nup|n=i" => \$nup, "8" => sub { $nup = 8 }, "crop|c" => \$crop, "book|b" => \$book, + "paper|p=s" => \$papersize, "margin|m=s" => \$margin ); die "I can handle only one file at the same time :P" @@ -52,7 +55,9 @@ for (my $n = $nup; $n > 1; $n /= 2) { unless $n % 2 == 0; } -$margin /= 2 if defined $crop; #&& $nup > 1; +#Note: $margin is ignored if $crop is unset +$margin = 0 unless defined $crop; +$margin /= 2; $remote = "localhost" @@ -97,6 +102,9 @@ if ($remote eq "localhost") { $command .= "$zip | ssh $remote \"$zcat - > /tmp/paf.ps; "; } +#$command .= "$psresize -p$papersize /tmp/paf.ps | "; +# useless, since the argument of $pscrop has to be seekable + if (defined $crop) { $command .= "$pscrop -m$margin /tmp/paf.ps | "; } else { @@ -107,7 +115,7 @@ $command .= "$psnup -p$papersize -m${margin}cm -$nup | "; $command .= "$psbook | " if defined $book; -$command .= "$ps2pdf - - "; +$command .= "$ps2pdf -sPAPERSIZE=$papersize - - "; $command .= "| $zip\" | $zcat " if ($remote ne "localhost"); @@ -116,3 +124,6 @@ $command .= "> /tmp/pouf.pdf"; print "$command", "\n"; system $command; + + +system ($pdfviewer, "/tmp/pouf.pdf"); |