Skip to content

Instantly share code, notes, and snippets.

@indy-singh
Forked from guifromrio/compress-pdf-with-gs.md
Created August 4, 2020 23:25
Show Gist options
  • Save indy-singh/45bc12154607a396b7ad8346c7f25285 to your computer and use it in GitHub Desktop.
Save indy-singh/45bc12154607a396b7ad8346c7f25285 to your computer and use it in GitHub Desktop.
Compress PDF files with ghostscript

This can reduce files to ~15% of their size (2.3M to 345K, in one case) with no obvious degradation of quality.

ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Other options for PDFSETTINGS:

  • /screen selects low-resolution output similar to the Acrobat Distiller "Screen Optimized" setting.
  • /ebook selects medium-resolution output similar to the Acrobat Distiller "eBook" setting.
  • /printer selects output similar to the Acrobat Distiller "Print Optimized" setting.
  • /prepress selects output similar to Acrobat Distiller "Prepress Optimized" setting.
  • /default selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file.

Source: http://ghostscript.com/doc/current/Ps2pdf.htm

@indy-singh
Copy link
Author

indy-singh commented Aug 4, 2020

I used:-

gswin64.exe -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

https://www.ghostscript.com/download/gsdnld.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment