Skip to content

Instantly share code, notes, and snippets.

@passos
Created February 19, 2024 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save passos/30c5c2decd0408e61c43160780d0a60c to your computer and use it in GitHub Desktop.
Save passos/30c5c2decd0408e61c43160780d0a60c to your computer and use it in GitHub Desktop.
compress by ghostscript
inputFile=$1
outputFile=$(echo $inputFile | sed 's|\.pdf$|\.c\.pdf|ig')
echo " input is $inputFile, \noutput is $outputFile"
while true; do
# Prompt the user
read -p "Do you want to continue? (Y/N): " answer
# Convert the input to lowercase
answer=$(echo "$answer" | tr '[:upper:]' '[:lower:]')
# Check the input
if [[ $answer == "y" ]]; then
break
elif [[ $answer == "n" ]]; then
exit
fi
done
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dBATCH -sOutputFile="$outputFile" "$inputFile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment