From 4eab173014a1d0a6029e55acb7ad672ea201e622 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Wed, 22 Sep 2010 00:57:26 +0200 Subject: Viewer --- pdftool.pl | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pdftool.pl b/pdftool.pl index 5136849..f10ecec 100755 --- a/pdftool.pl +++ b/pdftool.pl @@ -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"); -- cgit v1.2.3