Skip to content

Instantly share code, notes, and snippets.

@izikeros
Last active March 31, 2022 11:39
Show Gist options
  • Select an option

  • Save izikeros/6dfb6a78f2559678163e5dc0b49760fa to your computer and use it in GitHub Desktop.

Select an option

Save izikeros/6dfb6a78f2559678163e5dc0b49760fa to your computer and use it in GitHub Desktop.
Reduce size of pdf file using GhostScript
# Requires ghostscript installed.
# - On MacOSX: brew install ghostscript
# - On Windows: install binaries via https://www.ghostscript.com/
#
# use PDFSETTINGS: '/default','/prepress','/printer','/ebook','/screen'
# 0: default - almost identical to /screen
# 1: prepress - high quality, color preserving, 300 dpi imgs
# 2: printer - high quality, 300 dpi images
# 3: ebook - low quality, 150 dpi images
# 4: screen - screen-view-only quality, 72 dpi images
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS='/screen' -dNOPAUSE -dQUITET -dBATCH -sOutputFile="output.pdf" input.pdf
See python wrapper: https://github.com/theeko74/pdfc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment