From ae231eb475a935f53fad77cefe1d79748aa04fc6 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sun, 8 Jan 2012 22:41:27 +0100 Subject: auto-rotate --- pdftool.pl | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/pdftool.pl b/pdftool.pl index f92df3d..25cdfc5 100755 --- a/pdftool.pl +++ b/pdftool.pl @@ -28,7 +28,7 @@ pdftool.pl - a swiss army knife for PDF documents B [B<-w> I ] [B<-h> I] [B<-p> I] [B<-W> I] [B<-H> I] [B<-P> I] [B<-s> I] [B<-m> I] [B<-b> I] [B<-c>] [B<--book>] [B<--column>] -[B<-n> I] [B<--no-rotate>] [B<--ps>] [B<-q>] [I [I]] +[B<-n> I] [B<--auto-rotate>] [B<--ps>] [B<-q>] [I [I]] =head1 DESCRIPTION @@ -55,13 +55,6 @@ file name, B sends the data to the standard output. By default, B outputs a PDF document; see B<--ps> to get a PostScript instead. -By default, B rotates the pages in order to ensure that your -document will always be printable using your favorite duplex mode for portrait -documents (e.g., Tumble if you prefer to turn the pages like those of a -book - "vertical folding"; regardless of the orientation of the document). -See the B<--no-rotate> option to bypass this behavior e.g., to read the -output document on your screen. - B does the following passes on the input document: =over 4 @@ -178,12 +171,15 @@ Put multiple logical pages onto each physical sheet of paper. If I is less than 10, the option B<->I may be used as an alternative. -=item B<--no-rotate> +=item B<--auto-rotate> -By default, B ensures that your pdf will be printable using -your "default" duplex mode (see B). B<--no-rotate> tries to -make the output PDF ready to read on your computer instead. It has no -effect for portrait documents. +Auto-rotate the pages in order to ensure that your document will be +printable using your favorite duplex mode for portrait documents (e.g., +C if you prefer to turn the pages like those of a book - +"vertical folding"; regardless of the orientation of the document). +It has no effect if the input is a portrait document. +This flag might not be suitable if you plan to read the output document +on your screen. =item B<--ps> @@ -273,7 +269,7 @@ my $nup = 1; my $column; my $quiet; my $man; -my $norotate; +my $autorotate; my $psout; GetOptions( "select|s=s" => \$select, @@ -289,7 +285,7 @@ GetOptions( "select|s=s" => \$select, "book" => \$book, "ps" => \$psout, "nup|n=i" => \$nup, - "no-rotate" => \$norotate, + "auto-rotate"=> \$autorotate, "1" => sub { $nup = 1 }, "2" => sub { $nup = 2 }, "3" => sub { $nup = 3 }, @@ -714,7 +710,7 @@ sub psnup { if ((($bbox[2]-$bbox[0] > $bbox[3]-$bbox[1]) and not ($outwidth-2*$margin > $outheight-2*$margin)) or - (defined $norotate + (not (defined $autorotate) and not ($bbox[2]-$bbox[0] > $bbox[3]-$bbox[1]) and ($outwidth-2*$margin > $outheight-2*$margin))) { ($outheight, $outwidth) = ($outwidth, $outheight); @@ -821,7 +817,7 @@ sub psnup { ($ow,$oh) = ($oh,$ow) if $rotate%2; my $pagespecs; - if (defined $norotate || $ow < $oh) { + if (not (defined $autorotate) || $ow < $oh) { $pagespecs = $nup . ':' . join ('+', @ospecs); } else { $pagespecs = 2*$nup . ':' . join ('+', @ospecs) @@ -851,8 +847,8 @@ sub pswrite { ($ow,$oh) = ($oh,$ow) if $rotate%2; my $pagedevice; - if (defined $norotate || $oh < $oh || $landscape) { - $rotate = ($rotate+1)%4 if not (defined $norotate) and $oh < $ow; + if (not (defined $autorotate) || $oh < $oh || $landscape) { + $rotate = ($rotate+1)%4 if (defined $autorotate) and $oh < $ow; $pagedevice = "/Orientation $rotate /PageSize [$outwidth $outheight]"; } else { $pagedevice = "/PageSize [$outwidth $outheight]"; -- cgit v1.2.3