Resize pdf file from command line

Post date: Dec 9, 2011 5:29:02 PM

Sometimes the generated pdf file size can be large, especially when the file contains a lot of high-quality figures, so we might want to be able to reduce the file size. Adobe Acrobat (8) Professional has such an option; go to Document>Reduce File Size. What if we don't have the software...How can we reduce the pdf file size from the command line in Ubuntu? Here is how

  1. We must have Ghost script:
  2. Use the command
    1. gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
    2. to resize the original pdf file input.pdf and output the resized pdf file output.pdf.
  3. We can also adjust the quality of the resized file by specifying the option -dPDFSETTINGS parameter, for example
    1. gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -dPDFSETTINGS=/ebook -sOutputFile=output.pdf input.pdf

More details about the command can be found by typing

man gs

in the command line. Also I found the following URLs are very informative:

  • http://milan.kupcevic.net/ghostscript-ps-pdf/
  • http://www.ubuntugeek.com/ubuntu-tiphowto-reduce-adobe-acrobat-file-size-from-command-line.html