#!/bin/bash # # Syntax: ps4up [-p] [-h] psfile [...] # # Purpose: Creates a Postscript file from psfile in which 4 A4 pages are # scaled and put on 1 A4 page in portrait mode. # The name of the output file is the same as psfile but # with the extension .ps replaced by .4up.ps . # If the -p option is specified, the resulting Postscript file is # directly sent to the printer and not written to disk. # The -h flag shows the help info for this command. # # See also: mpage, mk_4up # Created: Jan 8, 1998 by Bart De Schutter # Last revised: Jan 19, 2004 by Bart De Schutter # # See http://www.deschutter.info/util/scripts.html for the latest version of # this script. # Status: public # Category: postscript if [ -z "$(type -p psnup)" ]; then echo >&2 echo >&2 "ERROR: the command psnup is not installed on this system." echo >&2 exit 1 fi print_file=0 while getopts :hp option do case "$option" in p) print_file=1;; h) sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 exit 1;; \?) echo >&2 echo >&2 "Unknown option: $OPTARG" echo >&2 sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 exit 1;; esac done shift $(($OPTIND-1)) if [ $# -eq 0 ]; then echo >&2 echo >&2 "ERROR: ${0##*/} requires at least 1 input argument." echo >&2 sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 exit 1 fi for fil in "$@" do inputfile=${fil%.ps} ps_in=${inputfile}.ps ps_out=${inputfile}.4up.ps if [ $print_file -eq 1 ]; then psnup -pA4 -4 "$ps_in" | lp else echo echo "Processing $ps_in -> $ps_out" psnup -pA4 -4 "$ps_in" "$ps_out" fi done