summaryrefslogtreecommitdiff
path: root/rc/bin/pdf2ps
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 17:14:36 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 17:14:36 +0300
commit2959e1ede0ebc6fdffd7b8660f43c2ce14c9696f (patch)
treef6343b1ce11a8c87251dd27cf3d3e26b50693fa7 /rc/bin/pdf2ps
parente463eb40363ff4c68b1d903f4e0cdd0ac1c5977f (diff)
Import sources from 2011-03-30 iso image - rc
Diffstat (limited to 'rc/bin/pdf2ps')
-rwxr-xr-xrc/bin/pdf2ps53
1 files changed, 53 insertions, 0 deletions
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