Skip to content

Instantly share code, notes, and snippets.

@mjm522
Created October 7, 2020 08:05
Show Gist options
  • Save mjm522/818ab694fc40f60d6100a17793c6e8a3 to your computer and use it in GitHub Desktop.
Save mjm522/818ab694fc40f60d6100a17793c6e8a3 to your computer and use it in GitHub Desktop.
Bash function to compress pdf
function compress_pdf()
{
input_file=$1
output_file=$1_compressed.pdf
level=/$2
#levels: screen > ebook > printer > prepress,
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=$level -sOutputFile=$output_file $input_file
echo "Saved in the same folder with name $output_file"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment