Skip to content

Instantly share code, notes, and snippets.

@aalexren
Created May 29, 2023 09:33
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 aalexren/d6a184160c080b15540a145f1be1b210 to your computer and use it in GitHub Desktop.
Save aalexren/d6a184160c080b15540a145f1be1b210 to your computer and use it in GitHub Desktop.
Deal with PDF on macOS using ghostscript

To use it, install it using homebrew:
brew install ghostscript

Then use one of theese commands for your needs:

  1. Compress PDF:
    gs -sDEVICE=pdfwrite -dNOPAUSE -dQUIET -dBATCH -dPDFSETTINGS=/screen -dCompatibilityLevel=1.4 -sOutputFile=output.pdf input.pdf
  2. Merge PDF:
    gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged.pdf source1.pdf source2.pdf source3.pdf

  1. https://blog.omgmog.net/post/compressing-pdf-from-your-mac-or-linux-terminal-with-ghostscript/
  2. https://apple.stackexchange.com/a/293198/321160
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment