Skip to content

Instantly share code, notes, and snippets.

@Leandros
Created April 2, 2019 08:55
Show Gist options
  • Save Leandros/c93ad782192b356d7e2ff36702e4ca10 to your computer and use it in GitHub Desktop.
Save Leandros/c93ad782192b356d7e2ff36702e4ca10 to your computer and use it in GitHub Desktop.
Compress PDF (requires ghostscript)
#!/bin/bash
readonly input="$1"
readonly output="$2"
readonly preset="$3"
if [ "$input" = "" ] || [ "$output" = "" ] || [ "$preset" = "" ]; then
echo "usage: $0 [input file] [output file] [screen|ebook|printer|prepress]"
exit 1
fi
gs -sDEVICE=pdfwrite -dNOPAUSE -dQUIET -dBATCH -dPDFSETTINGS=/${preset:-"screen"} -dCompatibilityLevel=1.4 -sOutputFile="$output" "$input"\
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment