summaryrefslogtreecommitdiff
path: root/localpdf2pdfscreen
blob: 9f5fc0dc1a14facdf682f631569e31f74e23add8 (plain)
  1. #!/bin/sh
  2. set -e
  3. PRG="$0"
  4. showhelp() {
  5. cat <<EOF
  6. Usage: $PRG INFILE [ OUTFILE ]
  7. If missing, OUTFILE is INFILE.pdf (ie. double pdf extension).
  8. Examples:
  9. $PRG newspaper.pdf newspaper_screenready.pdf
  10. EOF
  11. }
  12. exit1() {
  13. echo >&2 "ERROR: $1"
  14. exit 1
  15. }
  16. if [ $# -eq 0 ]; then
  17. showhelp
  18. exit1 "Not enough parameters"
  19. fi
  20. infile="$1"
  21. tmpfile=$(mktemp -t "$PRG.XXXXXXXXXX") || exit 1
  22. outfile="${2:-$infile.pdf}"
  23. [ ! -e "$outfile" ] || exit1 "Output file already exists"
  24. pdftops -paper match "$infile" "$tmpfile"
  25. ps2pdf -dPDFSETTINGS=/screen "$tmpfile" "$outfile"