Root/
| 1 | #!/bin/bash |
| 2 | # |
| 3 | # schps2pdf - Generate PDF files from 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 | |
| 15 | usage() |
| 16 | { |
| 17 | cat <<EOF 1>&2 |
| 18 | usage: $0 [options] [-o file.pdf] [file.ps ...] |
| 19 | |
| 20 | -t prefix make a table of content. Remove prefix from file names. |
| 21 | -T title make a table of content using the specified title. Each |
| 22 | sheet needs one -T option. |
| 23 | EOF |
| 24 | exit 1 |
| 25 | } |
| 26 | |
| 27 | |
| 28 | toc=false |
| 29 | out=- |
| 30 | while true; do |
| 31 | case "$1" in |
| 32 | -o) [ -z "$2" ] && usage |
| 33 | out=$2 |
| 34 | shift 2;; |
| 35 | -t) [ -z "$2" ] && usage |
| 36 | toc=true |
| 37 | prefix="$2" |
| 38 | shift 2;; |
| 39 | -T) [ -z "$2" ] && usage |
| 40 | toc=true |
| 41 | titles="$titles \"$2\"" |
| 42 | shift 2;; |
| 43 | -*) |
| 44 | usage;; |
| 45 | *) |
| 46 | break;; |
| 47 | esac |
| 48 | done |
| 49 | |
| 50 | in=${1:--} |
| 51 | shift |
| 52 | |
| 53 | eval gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=\"$out\" -f \ |
| 54 | `i=1; for n in "$in" "$@"; do \ |
| 55 | i=\`expr $i + 1\`; |
| 56 | echo "<(sheet=\"\`basename \"$n\" .ps\`\"; |
| 57 | set x $titles; eval t='\\${$i}'; |
| 58 | $toc && echo '[ /Title ('\"\\${t:-\\${sheet#$prefix}}\"') /OUT pdfmark'; |
| 59 | cat \"$n\";)"; done` |
| 60 |
Branches:
master
