summaryrefslogtreecommitdiffstats
path: root/pdftool.pl
blob: 269825ddf4884f23ca172bec50126b6c4338b41a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#! /usr/bin/perl

use Getopt::Long; 
use warnings;
use strict;

Getopt::Long::Configure ("bundling");

my $remote      = 'graal';

my $pdf2ps      = 'pdftops';
my $ps2pdf      = 'ps2pdf';
my $pscrop      = 'psnup2.pl -s1 -l1';
my $psnup       = 'psnup';
my $psbook      = 'psbook';
my ($zip,$zcat) = ('bzip2','bzcat');

open(PAPERSIZE, "/etc/papersize")
    or die "Couldn't read `/etc/papersize'";
my $papersize   = <PAPERSIZE>;
chomp $papersize
    or die "Couldn't read papersize";
close PAPERSIZE;


my $nup      = 1;
my $margin  = 1;
#TODO: units
my $crop;
my $book;

GetOptions( "nup|n=i"    => \$nup,
            "1"          => sub { $nup = 1 },
            "2"          => sub { $nup = 2 },
            "4"          => sub { $nup = 4 },
            "8"          => sub { $nup = 8 },
            "crop|c"     => \$crop,
            "book|b"     => \$book,
            "margin|m=s" => \$margin );


for (my $n = $nup; $n > 1; $n /= 2) {
    die "nup should be a power of two"
        unless $n % 2 == 0;
}


print $nup, "\n";