File: plot2pdf.sh

package info (click to toggle)
ghostscript 10.05.1~dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 93,508 kB
  • sloc: ansic: 908,895; python: 7,676; cpp: 6,534; cs: 6,457; sh: 6,168; java: 4,028; perl: 2,373; tcl: 1,639; makefile: 529; awk: 66; yacc: 18
file content (29 lines) | stat: -rwxr-xr-x 954 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash

# Produce a trimmed HPGL/2 RTL plot.  Ignore the Plot Size command in
# the RTL/GL2 file and produce output whose extant corresponds to the
# bounding box of all the graphics in the plot.  This requires 2
# passes over the file.

for f in $*
do
    # get the bounding box in points.
    BBOX_PTS=( $(gpcl6 -dNOPAUSE -lRTL -sDEVICE=bbox $f 2>&1 |\
       grep "%%BoundingBox" | awk '{print $2, $3, $4, $5}') )

    # convert to plotter units
    SF="(1016.0/72.0)"
    for coord in 0 1 2 3
    do
        BBOX_PLU[$coord]=$(echo "scale=2;${BBOX_PTS[$coord]} * $SF"|bc)
    done

    # now run pcl with our new coordinates.  Annoyingly those @PJL's
    # need to start in the first colummn, as no leading space is
    # allowed by the PJL parser.
    gpcl6 -lRTL \
      -J"@PJL DEFAULT PLOTSIZEOVERRIDE=ON;\
@PJL DEFAULT PLOTSIZE1=${BBOX_PLU[2]};\
@PJL DEFAULT PLOTSIZE2=${BBOX_PLU[3]}"\
    -sDEVICE=pdfwrite -o "$(basename $f).pdf" $f
done