changelog shortlog tags branches changeset files revisions annotate raw help

Mercurial > hg > plan9front / rc/bin/ps2pdf

changeset 7243: 34f64dcbbc25
parent: efddda59690a
author: cinap_lenrek@felloff.net
date: Fri, 17 May 2019 18:14:10 +0200
permissions: -rwxr-xr-x
description: 7l: don't hardcode 4k pagesize, use INITRND
1 #!/bin/rc
2 # ps2pdf - convert PostScript to PDF
3 rfork e
4 
5 fn usage {
6  echo 'usage: ps2pdf [gs-options] [input.ps [output.pdf]]' >[1=2]
7  exit usage
8 }
9 
10 # gs's pdfwrite sometimes emits bad pdf at level 1.2,
11 # but 1.4 seems to work fine.
12 compat=(-'dCompatibilityLevel=1.2')
13 opt=()
14 while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 - --){
15  if(~ $1 '-dCompatibilityLevel='*)
16  compat=()
17  opt=($opt $1)
18  shift
19 }
20 if(~ $1 --)
21  shift
22 
23 switch($#*){
24 case 0
25  fin='-'
26  fout='-'
27 case 1
28  fin=$1
29  fout='-'
30 case 2
31  fin=$1
32  fout=$2
33 case *
34  usage
35 }
36 
37 # We have to include the options twice because -I only takes effect
38 # if it appears before other options.
39 
40 gscmd=( gs $opt -dSAFER -dNOPAUSE -dBATCH -q -s'DEVICE=pdfwrite' \
41  $opt $compat \
42  -s'OutputFile='$fout -c .setpdfwrite -f $fin)
43 exec $gscmd