From 2959e1ede0ebc6fdffd7b8660f43c2ce14c9696f Mon Sep 17 00:00:00 2001 From: Taru Karttunen Date: Wed, 30 Mar 2011 17:14:36 +0300 Subject: Import sources from 2011-03-30 iso image - rc --- rc/bin/pdf2ps | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 rc/bin/pdf2ps (limited to 'rc/bin/pdf2ps') diff --git a/rc/bin/pdf2ps b/rc/bin/pdf2ps new file mode 100755 index 000000000..9dfc200bb --- /dev/null +++ b/rc/bin/pdf2ps @@ -0,0 +1,53 @@ +#!/bin/rc +# pdf2ps [gs-options] [input.pdf] [output.ps] - generate PS from PDF +rfork e + +fn cleanup { } +fn usage { + echo 'usage: pdf2ps [gs-options] [input.pdf] [output.ps]' >[1=2] + exit usage +} + +lang=(-'dLanguageLevel=2') +opt=() +while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 - --){ + if(~ $1 '-dLanguageLevel='*) + lang=() + 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 +} + +if(~ $fin -){ + # fin=/tmp/pdf2ps.$pid.^`{date -n} + # fn cleanup { rm -f $fin } + # cat >$tmp + 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. + +gs $opt -dSAFER -dNOPAUSE -dBATCH -q -s'DEVICE=pswrite' \ + $opt $lang \ + -s'OutputFile='$fout -c save pop -f $fin + +cleanup -- cgit v1.2.3