Created
October 10, 2019 20:43
-
-
Save username1290/f8c4f1f60eb9cd57a117b5e0af18f6c2 to your computer and use it in GitHub Desktop.
Compress PDF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://blog.omgmog.net/post/compressing-pdf-from-your-mac-or-linux-terminal-with-ghostscript/ | |
brew install ghostscript | |
# If you’re using Linux you can install ghostscript from aptitude, or your package manager of choice [2]. | |
# Now, you can use ghostscript to compress your PDF file for the web: | |
gs -sDEVICE=pdfwrite -dNOPAUSE -dQUIET -dBATCH -dPDFSETTINGS=/screen -dCompatibilityLevel=1.4 -sOutputFile=output.pdf input.pdf | |
# That’s not exactly a memorable command, so I’ve made a function that you can add to your ~/.bash_profile to allow you to easily compress PDF files from your terminal: | |
------------------------------- | |
# Usage: compresspdf [input file] [output file] [screen*|ebook|printer|prepress] | |
compresspdf() { | |
gs -sDEVICE=pdfwrite -dNOPAUSE -dQUIET -dBATCH -dPDFSETTINGS=/${3:-"screen"} -dCompatibilityLevel=1.4 -sOutputFile="$2" "$1" | |
} | |
------------------------------- | |
Now you can simply run the following command: | |
compresspdf "Massive.pdf" "Small.pdf" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment