xref: /plan9/sys/src/cmd/gs/lib/ps2pdfwr (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1#!/bin/sh
2# $Id: ps2pdfwr,v 1.10 2004/08/04 00:55:46 giles Exp $
3# Convert PostScript to PDF without specifying CompatibilityLevel.
4
5# This definition is changed on install to match the
6# executable name set in the makefile
7GS_EXECUTABLE=gs
8
9OPTIONS="-dSAFER"
10while true
11do
12	case "$1" in
13	-?*) OPTIONS="$OPTIONS $1" ;;
14	*)  break ;;
15	esac
16	shift
17done
18
19if [ $# -lt 1 -o $# -gt 2 ]; then
20	echo "Usage: `basename $0` [options...] (input.[e]ps|-) [output.pdf|-]" 1>&2
21	exit 1
22fi
23
24infile="$1";
25
26if [ $# -eq 1 ]
27then
28	case "${infile}" in
29	  -)		outfile=- ;;
30	  *.eps)	base=`basename "${infile}" .eps`; outfile="${base}.pdf" ;;
31	  *.ps)		base=`basename "${infile}" .ps`; outfile="${base}.pdf" ;;
32	  *)		base=`basename "${infile}"`; outfile="${base}.pdf" ;;
33	esac
34else
35	outfile="$2"
36fi
37
38# We have to include the options twice because -I only takes effect if it
39# appears before other options.
40exec $GS_EXECUTABLE $OPTIONS -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite "-sOutputFile=$outfile" $OPTIONS -c .setpdfwrite -f "$infile"
41