/usr/bin/gri_unpage is in gri 2.12.23-8.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | #!/usr/bin/perl
$usage = "
PURPOSE: Chop multipage Gri PostScript file into one file per page.
USAGE: gri_unpage name.ps -- create files name-1.ps, name-2.ps, etc, one
for each page of name.ps.
gri_unpage -h -- print this help message
-l -- set bounding box to letter page 612x792
BUGS: 1. Bounding box is always the same for all pages.
2. Assumes that all Gri fonts are used even if they aren't.
";
eval { use Getopt::Std; ; };
my $use_getopts = $@ ? 0 : 1;
if ($use_getopts) {
&getopts('hl');
if ($opt_h) {
print "$usage";
exit 0;
}
}
if ($#ARGV != 0) {
die "Wrong number of arguments.\n$usage\n";
}
# Scan for BoundingBox to use that for each page.
if (! $use_getopts || ! $opt_l) {
open(IN, $ARGV[0]) || die "Cannot open input file `$ARGV[0]'\n";
while(<IN>) {
if (/%%BoundingBox: [0-9 ]+/) {
$boundingBox = $_;
chop($boundingBox);
last;
}
}
close(IN);
}
if (! defined($boundingBox)) {
$boundingBox = "%%BoundingBox: 0 0 612 792";
}
$file = $ARGV[0];
$file =~ s/\.ps$//;
open(IN, $ARGV[0]) || die "Cannot open input file `$ARGV[0]'\n";
$prologue = "";
while(<IN>) {
$prologue .= $_;
last if (/%%EndProlog/);
}
$epilog = "
%%Trailer
$boundingBox
%%DocumentFonts: Courier Helvetica Palatino-Roman Palatino-Italic Symbol Times-Roman
%%Pages: 1
";
$page = 0;
while(<IN>) {
if (/%%Page:/) {
$page++;
if ($page < 10) {
$name = sprintf("$file-0%d.ps", $page);
} else {
$name = sprintf("$file-%d.ps", $page);
}
if ($page != 1) {
print OUT $epilog;
close(OUT);
}
print STDERR "Creating file $name\n";
open(OUT, ">$name") || die "Cannot open output file `$name'\n";
print OUT $prologue;
} else {
print OUT;
}
}
close OUT if ($page != 0);
|