Skip to content

Instantly share code, notes, and snippets.

@LordAmit
Last active February 19, 2022 21:50
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 LordAmit/3dbb7fc9caad09b3fa71d9e2d21ab794 to your computer and use it in GitHub Desktop.
Save LordAmit/3dbb7fc9caad09b3fa71d9e2d21ab794 to your computer and use it in GitHub Desktop.
Using GhostScript to optimize PDF file size while maintaining full texts
#!/bin/sh
# /screen can be changed to the following:
# /screen selects low-resolution output similar to the Acrobat Distiller (up to version X) "Screen Optimized" setting.
# /ebook selects medium-resolution output similar to the Acrobat Distiller (up to version X) "eBook" setting.
# /printer selects output similar to the Acrobat Distiller "Print Optimized" (up to version X) setting.
# /prepress selects output similar to Acrobat Distiller "Prepress Optimized" (up to version X) setting.
# /default selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file.
# from https://www.ghostscript.com/doc/9.54.0/VectorDevices.htm
# Script copied and modified from https://stackoverflow.com/questions/10450120/optimize-pdf-files-with-ghostscript-or-other
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -sOutputFile=output.pdf $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment