Root/eeshow/sch2pdf

1#!/bin/bash
2#
3# sch2pdf - Generate PDF from schematics, using eeshow
4#
5# Written 2016 by Werner Almesberger
6# Copyright 2016 by 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# Known bugs:
16# - expects first sheet to be index page
17# - only renders sub-sheets
18# - has all the limitations of eeshow (see TODO)
19#
20
21
22usage()
23{
24    cat <<EOF 1>&2
25usage: $0 [-n first_num] [-o output.pdf] [-q] [-t template.fig ]
26      file.lib ... file.sch
27EOF
28    exit 1
29}
30
31
32out=out.pdf
33quiet=false
34template=
35num=1
36while [ "$1" ]; do
37    case "$1" in
38    -n) num=$2
39        shift 2;;
40    -o) out=$2
41        shift 2;;
42    -q) quiet=true
43        shift;;
44    -t) template="-t $2"
45        shift 2;;
46    -*) usage;;
47    *) break;;
48    esac
49done
50
51[ "$1" ] || usage
52
53libs=
54while [ "$2" ]; do
55    libs="$libs $1"
56    shift
57done
58
59./eeshow $libs "$1" \
60    -- fig $template "TITLE=`basename \"$1\" .sch`" NUMBER=$num |
61    fig2dev -L pdf >"$out"
62
63sheet=false
64while read line; do
65    if ! $sheet; then
66        [ "${line#\$Sheet}" != "$line" ] && sheet=true
67        continue
68    else
69        if [ "${line#\$EndSheet}" != "$line" ]; then
70            sheet=false
71            continue
72        fi
73    fi
74
75    if [ "${line#F0 \"}" != "$line" ]; then
76        name=${line#F0 \"}
77        name=${name%%\"*}
78    fi
79    [ "${line#F1 \"}" = "$line" ] && continue
80    file=${line#F1 \"}
81    file=${file%%\"*}
82
83    num=`expr $num + 1`
84
85    $quiet || echo "$file" 1>&2
86    ./eeshow $libs `dirname "$1"`/$file \
87        -- fig $template "TITLE=$name" NUMBER=$num |
88        fig2dev -L pdf >_tmp.pdf
89    pdfunite "$out" _tmp.pdf _tmp2.pdf
90    mv _tmp2.pdf "$out"
91done <"$1"
92exit
93

Archive Download this file

Branches:
master



interactive