Skip to content

Instantly share code, notes, and snippets.

@vargheseraphy
Created January 30, 2015 07:26
Show Gist options
  • Save vargheseraphy/6b43816abb14bdc73c27 to your computer and use it in GitHub Desktop.
Save vargheseraphy/6b43816abb14bdc73c27 to your computer and use it in GitHub Desktop.
Pdf Compression and reduction
qpdf --linearize input.pdf output.pdf
I had the same problem and found two different solutions (see this thread for more details). Both reduced the size of my uncompressed PDF dramatically.
Pixelated (lossy):
convert input.pdf -compress Zip output.pdf
Unpixelated (lossless, but may display slightly differently):
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dBATCH -dQUIET -sOutputFile=output.pdf input.pdf
Edit: I just discovered another option (for lossless compression), which avoids the nasty gs command. qpdf is a neat tool that converts PDFs (compression/decompression, encryption/decryption), and is much faster than the gs command:
qpdf --linearize input.pdf output.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment