summaryrefslogtreecommitdiff
path: root/sch2pdf
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-02 14:00:08 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-08-02 14:00:08 (GMT)
commit8745b40e3eb216fc5cfa7373fea3b4ae991f1c3e (patch)
treeeab2aa7ec1941bd3da99f1dbcf64eab04d34667a /sch2pdf
downloadeeshow-8745b40e3eb216fc5cfa7373fea3b4ae991f1c3e.zip
eeshow-8745b40e3eb216fc5cfa7373fea3b4ae991f1c3e.tar.gz
eeshow-8745b40e3eb216fc5cfa7373fea3b4ae991f1c3e.tar.bz2
rename sch2fig to eeshow
Diffstat (limited to 'sch2pdf')
-rwxr-xr-xsch2pdf92
1 files changed, 92 insertions, 0 deletions
diff --git a/sch2pdf b/sch2pdf
new file mode 100755
index 0000000..8e3c275
--- /dev/null
+++ b/sch2pdf
@@ -0,0 +1,92 @@
+#!/bin/bash
+#
+# sch2pdf - Generate PDF from schematics, using eeshow
+#
+# Written 2016 by Werner Almesberger
+# Copyright 2016 by Werner Almesberger
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+
+#
+# Known bugs:
+# - expects first sheet to be index page
+# - only renders sub-sheets
+# - has all the limitations of eeshow (see TODO)
+#
+
+
+usage()
+{
+ cat <<EOF 1>&2
+usage: $0 [-n first_num] [-o output.pdf] [-q] [-t template.fig ]
+ file.lib ... file.sch
+EOF
+ exit 1
+}
+
+
+out=out.pdf
+quiet=false
+template=
+num=1
+while [ "$1" ]; do
+ case "$1" in
+ -n) num=$2
+ shift 2;;
+ -o) out=$2
+ shift 2;;
+ -q) quiet=true
+ shift;;
+ -t) template="-t $2"
+ shift 2;;
+ -*) usage;;
+ *) break;;
+ esac
+done
+
+[ "$1" ] || usage
+
+libs=
+while [ "$2" ]; do
+ libs="$libs $1"
+ shift
+done
+
+./eeshow $libs "$1" \
+ -- fig $template "TITLE=`basename \"$1\" .sch`" NUMBER=$num |
+ fig2dev -L pdf >"$out"
+
+sheet=false
+while read line; do
+ if ! $sheet; then
+ [ "${line#\$Sheet}" != "$line" ] && sheet=true
+ continue
+ else
+ if [ "${line#\$EndSheet}" != "$line" ]; then
+ sheet=false
+ continue
+ fi
+ fi
+
+ if [ "${line#F0 \"}" != "$line" ]; then
+ name=${line#F0 \"}
+ name=${name%%\"*}
+ fi
+ [ "${line#F1 \"}" = "$line" ] && continue
+ file=${line#F1 \"}
+ file=${file%%\"*}
+
+ num=`expr $num + 1`
+
+ $quiet || echo "$file" 1>&2
+ ./eeshow $libs `dirname "$1"`/$file \
+ -- fig $template "TITLE=$name" NUMBER=$num |
+ fig2dev -L pdf >_tmp.pdf
+ pdfunite "$out" _tmp.pdf _tmp2.pdf
+ mv _tmp2.pdf "$out"
+done <"$1"
+exit