changelog shortlog tags branches changeset files revisions annotate raw help

Mercurial > hg > plan9front / rc/bin/pdf2ps

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 # pdf2ps [gs-options] [input.pdf] [output.ps] - generate PS from PDF
3 rfork e
4 
5 fn cleanup { }
6 fn usage {
7  echo 'usage: pdf2ps [gs-options] [input.pdf] [output.ps]' >[1=2]
8  exit usage
9 }
10 
11 lang=(-'dLanguageLevel=2')
12 opt=()
13 while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 - --){
14  if(~ $1 '-dLanguageLevel='*)
15  lang=()
16  opt=($opt $1)
17  shift
18 }
19 if(~ $1 --)
20  shift
21 
22 switch($#*){
23 case 0
24  fin=-
25  fout=-
26 case 1
27  fin=$1
28  fout=-
29 case 2
30  fin=$1
31  fout=$2
32 case *
33  usage
34 }
35 
36 if(~ $fin -){
37  # fin=/tmp/pdf2ps.$pid.^`{date -n}
38  # fn cleanup { rm -f $fin }
39  # cat >$tmp
40  fin=/fd/0
41 }
42 if(~ $fout -)
43  fout=/fd/1
44 
45 # Doing an inital `save' helps keep fonts from being flushed between
46 # pages. We have to include the options twice because -I only takes
47 # effect if it appears before other options.
48 
49 gs $opt -dSAFER -dNOPAUSE -dBATCH -q -s'DEVICE=pswrite' \
50  $opt $lang \
51  -s'OutputFile='$fout -c save pop -f $fin
52 
53 cleanup