Root/schhist/normalizeschps

1#!/bin/sh
2#
3# normalizeschps - Normalize eeschema Postscript
4#
5# Written 2010 by Werner Almesberger
6# Copyright 2010 Werner Almesberger
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13
14
15usage()
16{
17    cat <<EOF 1>&2
18usage: $0 [options] [in.ps [out.ps]]
19
20  -w points Postscript line width (default: use the original)
21EOF
22    exit 1
23}
24
25
26width=
27while true; do
28    case "$1" in
29    -w) [ -z "$2" ] && usage
30    width="$2"
31    shift 2;;
32    -*)
33    usage;;
34    *)
35    break;;
36    esac
37done
38
39[ -z "$3" ] || usage
40in=${1:--}
41out=${2:-/dev/stdout}
42
43sed '
44  1c%!PS-Adobe-3.0\
45  currentdict /DidNormalize known not { \
46      '"`[ -z \"$width\" ] ||
47        echo \"/setlinewidth { $width 2 copy lt { exch } if pop \
48        setlinewidth } bind def \"`"' \
49      /rectfill { rectstroke } bind def \
50      /DidNormalize true def \
51  } if \
52  gsave
53  /%%DocumentMedia: A4.*/a-20 -10 translate
54  /%%DocumentMedia: A3.*/{s/A3/A4/;a-20 -10 translate 0.70 dup scale
55  }
56  /%%DocumentMedia: A2.*/{s/A2/A4/;a-18 -12 translate 0.49 dup scale
57  }
58  $agrestore' "$in" >"$out"
59
60# /%%Orientation: Landscape/d' "$n"
61

Archive Download this file

Branches:
master



interactive