blob: 06240e07c3a76d598f61d98113dc60add20586ea (
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
50
51
52
53
54
55
56
57
58
59
60
|
#!/bin/sh
com=`basename $0`
files=$*
ROFF=groff
ROFF_FLAGS="-C -man -Tps"
CSPLIT=
IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:"
for i in $PATH; do
if [ -f $i/gcsplit ]; then
CSPLIT=$i/gcsplit
break
fi
if [ -f $i/csplit ]; then
CSPLIT=$i/csplit
break
fi
done
IFS="$save_ifs"
if [ "$files" = "" ]; then
echo "Usage: $com file [file2 ...]"
exit 1
fi
for file in $files
do
filename=`basename $file | awk -F. '{print $1}'`
eval $ROFF $ROFF_FLAGS $file > $filename.ps
pages=`grep '%%Pages\:' $filename.ps | awk '{print $2}'`
pp=`expr $pages - 1`
echo $filename': '$pages' pages'
if [ "$CSPLIT"x != x ]; then
$CSPLIT -k $filename.ps /Page:/ \{$pp\} > /dev/null
counter=0
for number in `ls xx*`
do
cat xx00 > $filename$counter.ps
echo '0.85 dup scale' >> $filename$counter.ps
cat $number >> $filename$counter.ps
if [ $counter != $pages ];
then
echo '%%Trailer' >> $filename$counter.ps
echo 'end' >> $filename$counter.ps
echo '%%EOF' >> $filename$counter.ps
fi
counter=`expr $counter + 1`
done
rm $filename.ps $filename'0.ps' xx*
else
echo "Can't find the csplit command. You'll have to split $filename.ps manually."
fi
done
|