Plan 9 from Bell Labs’s /usr/web/sources/contrib/someone/root/rc/bin/ps2pdf

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


#!/bin/rc
# ps2pdf - convert postscript to PDF
rfork e

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

if (~ $cputype riscv64) {		# see /*64/bin/page
	curdir=`{pwd}
	cpu -h $pccpu -c 'bindterm; cd '^$curdir^'; ps2pdf '^$"*
	exit ''
}

compat=(-'dCompatibilityLevel=1.2')
opt=()
while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 - --){
	if(~ $1 '-dCompatibilityLevel='*)
		compat=()
	opt=($opt $1)
	shift
}
if(~ $1 --)
	shift

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

# We have to include the options twice because -I only takes effect
# if it appears before other options.

gscmd=( gs $opt -dSAFER -dNOPAUSE -dBATCH -q -s'DEVICE=pdfwrite' \
	$opt $compat -s'OutputFile='$fout -c .setpdfwrite -f $fin)
exec $gscmd

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.