Debian Codegraph @

texmf-dist/doc/latex/latex4musicians/Figures/pdfcrop.sh

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 # pdfcrop.sh
4 # Guido Gonzato, PhD. GPL 2 or later.
5
6 MYSELF=$(basenamescip-shell system . . basename. $0)
7
8 if [scip-shell system . . `[`. $# -eq 0 ] ; then
9 printfscip-shell system . . printf. "Usage: ${MYSELF} <file.pdf>\n"
10 printfscip-shell system . . printf. "This script uses 'gs' to crop a one-page pdf file.\n\n"
11 exit 1
12 fi
13
14 # GhostScript for Windows must be installed in C:\Gs
15 # GS=/c/gs/gs9.26/bin/gswin64c.exe
16 # GNU/Linux and others:
17 GS=/usr/bin/gsscip-shell filesystem . . `/usr/bin/gs`.
18
19 INPUT=$1
20 PDF=$(basenamescip-shell system . . basename. $1 .pdf)
21 OUTPUT=$PDF-crop.pdf
22 GSOPTS="-q -sDEVICE=bbox -dBATCH -dNOPAUSE"
23
24 # find out the bounding box
25 $GS $GSOPTS $INPUT 2>&1 | grepscip-shell system . . grep. "%%B" > $PDF.bbox
26
27 # read bbox coordinates in variables
28 read tmp X1 Y1 X2 Y2 < $PDF.bbox
29
30 # write the output, cropped to bbox
31 $GS -q -o $OUTPUT \
32 -sDEVICE=pdfwrite \
33 -c "[ /CropBox [$X1 $Y1 $X2 $Y2] /PAGES pdfmark" \
34 -f $INPUT
35
36 /bin/rmscip-shell filesystem . . `/bin/rm`. -f $PDF.bbox
37
38 echoscip-shell system . . echo. "$INPUT cropped to $OUTPUT"