diff options
author | Karl Berry <karl@freefriends.org> | 2019-01-19 22:05:06 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-01-19 22:05:06 +0000 |
commit | a15d49c6003171553f50653d7b44a026af15742e (patch) | |
tree | dd791a1fc89878bb30f08cad7ca88d8ea698f5c2 /Master/texmf-dist/doc/latex/latex4musicians/pdfcrop.sh | |
parent | e2ba4464ce3c3f9a46280a5bad26523f952eed3e (diff) |
latex4musicians (19jan19)
git-svn-id: svn://tug.org/texlive/trunk@49759 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/latex4musicians/pdfcrop.sh')
-rw-r--r-- | Master/texmf-dist/doc/latex/latex4musicians/pdfcrop.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/latex4musicians/pdfcrop.sh b/Master/texmf-dist/doc/latex/latex4musicians/pdfcrop.sh new file mode 100644 index 00000000000..87430839bf2 --- /dev/null +++ b/Master/texmf-dist/doc/latex/latex4musicians/pdfcrop.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +# pdfcrop.sh +# Guido Gonzato, PhD. GPL 2 or later. + +MYSELF=$(basename $0) + +if [ $# -eq 0 ] ; then + printf "Usage: ${MYSELF} <file.pdf>\n" + printf "This script uses 'gs' to crop a one-page pdf file.\n\n" + exit 1 +fi + +# GhostScript for Windows must be installed in C:\Gs +# GS=/c/gs/gs9.26/bin/gswin64c.exe +# GNU/Linux and others: +GS=/usr/bin/gs + +INPUT=$1 +PDF=$(basename $1 .pdf) +OUTPUT=$PDF-crop.pdf +GSOPTS="-q -sDEVICE=bbox -dBATCH -dNOPAUSE" + +# find out the bounding box +$GS $GSOPTS $INPUT 2>&1 | grep "%%B" > $PDF.bbox + +# read bbox coordinates in variables +read tmp X1 Y1 X2 Y2 < $PDF.bbox + +# write the output, cropped to bbox +$GS -q -o $OUTPUT \ + -sDEVICE=pdfwrite \ + -c "[ /CropBox [$X1 $Y1 $X2 $Y2] /PAGES pdfmark" \ + -f $INPUT + +/bin/rm -f $PDF.bbox + +echo "$INPUT cropped to $OUTPUT" |