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
- We must have Ghost script:
- Use the command
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
- to resize the original pdf file input.pdf and output the resized pdf file output.pdf.
- We can also adjust the quality of the resized file by specifying the option -dPDFSETTINGS parameter, for example
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