xref: /plan9/sys/src/cmd/gs/lib/pdf2ps (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1#!/bin/sh
2# $Id: pdf2ps,v 1.7 2004/08/04 00:55:46 giles Exp $
3# Convert PDF to PostScript.
4
5# This definition is changed on install to match the
6# executable name set in the makefile
7GS_EXECUTABLE=gs
8
9OPTIONS=""
10while true
11do
12	case "$1" in
13	-?*) OPTIONS="$OPTIONS $1" ;;
14	*)  break ;;
15	esac
16	shift
17done
18
19if [ $# -eq 2 ]
20then
21    outfile=$2
22elif [ $# -eq 1 ]
23then
24    outfile=`basename "$1" \.pdf`.ps
25else
26    echo "Usage: `basename $0` [-dASCII85EncodePages=false] [-dLanguageLevel=1|2|3] input.pdf [output.ps]" 1>&2
27    exit 1
28fi
29
30# Doing an initial 'save' helps keep fonts from being flushed between pages.
31# We have to include the options twice because -I only takes effect if it
32# appears before other options.
33exec $GS_EXECUTABLE $OPTIONS -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pswrite "-sOutputFile=$outfile" $OPTIONS -c save pop -f "$1"
34