diff options
author | Jonas Smedegaard <dr@jones.dk> | 2008-03-17 12:18:09 +0000 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2008-03-17 12:18:09 +0000 |
commit | 48a658728a36b7e4e2df161c8a1e9195ea730821 (patch) | |
tree | 893b8d1bc85fedf3ed55e3e09759cc1261cd54b6 | |
parent | ca439068c7547aff76d250098cd41602699e4b06 (diff) |
Add new script to downsample PDF files.
-rwxr-xr-x | localpdf2pdfscreen | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/localpdf2pdfscreen b/localpdf2pdfscreen new file mode 100755 index 0000000..9f5fc0d --- /dev/null +++ b/localpdf2pdfscreen @@ -0,0 +1,37 @@ +#!/bin/sh + +set -e + +PRG="$0" + +showhelp() { + cat <<EOF +Usage: $PRG INFILE [ OUTFILE ] + +If missing, OUTFILE is INFILE.pdf (ie. double pdf extension). + +Examples: + $PRG newspaper.pdf newspaper_screenready.pdf + +EOF +} + +exit1() { + echo >&2 "ERROR: $1" + exit 1 +} + +if [ $# -eq 0 ]; then + showhelp + exit1 "Not enough parameters" +fi + + +infile="$1" +tmpfile=$(mktemp -t "$PRG.XXXXXXXXXX") || exit 1 +outfile="${2:-$infile.pdf}" + +[ ! -e "$outfile" ] || exit1 "Output file already exists" + +pdftops -paper match "$infile" "$tmpfile" +ps2pdf -dPDFSETTINGS=/screen "$tmpfile" "$outfile" |