Plan 9 from Bell Labs’s /usr/web/sources/plan9/rc/bin/pdf2ps

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc
# pdf2ps [-e] [gs-options] [input.pdf [output.ps]] - generate (e)ps from pdf
rfork e

fn usage {
	echo 'usage: pdf2ps [-e] [gs-options] [input.pdf [output.ps]]' >[1=2]
	exit usage
}

outdev=pswrite
fin=/fd/0
fout=/fd/1
lang=(-'dLanguageLevel=2')
opt=()
while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 - --){
	if(~ $1 '-dLanguageLevel='*)
		lang=()
	if not if(~ '-?' $1)
		usage
	if(~ $1 -e)
		outdev=epswrite
	if not
		opt=($opt $1)
	shift
}
if(~ $1 --)
	shift

switch($#*){
case 0
	;
case 1
	fin=$1
case 2
	fin=$1
	fout=$2
case *
	usage
}

if(~ $fin -)
	fin=/fd/0
if(~ $fout -)
	fout=/fd/1

# Doing an inital `save' helps keep fonts from being flushed between
# pages.  We have to include the options twice because -I only takes
# effect if it appears before other options.

exec gs $opt -dSAFER -dNOPAUSE -dBATCH -q -s'DEVICE='$outdev $opt $lang \
	-s'OutputFile=-' -c save pop -f $fin >$fout

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.