diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 17:14:36 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 17:14:36 +0300 |
commit | 2959e1ede0ebc6fdffd7b8660f43c2ce14c9696f (patch) | |
tree | f6343b1ce11a8c87251dd27cf3d3e26b50693fa7 /rc/bin/ps2pdf | |
parent | e463eb40363ff4c68b1d903f4e0cdd0ac1c5977f (diff) | |
download | plan9front-2959e1ede0ebc6fdffd7b8660f43c2ce14c9696f.tar.xz |
Import sources from 2011-03-30 iso image - rc
Diffstat (limited to 'rc/bin/ps2pdf')
-rwxr-xr-x | rc/bin/ps2pdf | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/rc/bin/ps2pdf b/rc/bin/ps2pdf new file mode 100755 index 000000000..9942b161a --- /dev/null +++ b/rc/bin/ps2pdf @@ -0,0 +1,43 @@ +#!/bin/rc +# ps2pdf - convert PostScript to PDF +rfork e + +fn usage { + echo 'usage: ps2pdf [gs-options] [input.ps [output.pdf]]' >[1=2] + exit usage +} + +# gs's pdfwrite sometimes emits bad pdf at level 1.2, +# but 1.4 seems to work fine. +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 |