Apr 072013
 

On many occasions, you might want to resize a PDF to send it by Email or put it on the web, today I had more than 50MB of PDF to be put as attachment of an article, and that was really too much. Using Linux you just need the program ghostscript to do everything and with a few commands you’ll have your resized documents.

For example my 50MB of documents become 15MB once I resized the PDF keeping a good quality, much better,


As first thing install ghostscript, for Ubuntu/Debian and Mint you just have to run this command from the terminal:

sudo apt-get install ghostscript

And now to resize your pdf you can use this command:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Replace the file names output.pdf and input.pdf with your file names.
These are the options that you can use to select the quality of the output:

-dPDFSETTINGS=/screen   (screen-view-only quality, 72 dpi images)
-dPDFSETTINGS=/ebook    (low quality, 150 dpi images)
-dPDFSETTINGS=/printer  (high quality, 300 dpi images)
-dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs)
-dPDFSETTINGS=/default  (almost identical to /screen)

Popular Posts:

Flattr this!

  One Response to “Resize pdfs from the command line in Linux”

  1. Ottima guida… 🙂
    Da 22,5 Mb a 6,5 Mb. Un grande risultato per un neofita “copia e incolla” come me.
    Grazie

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

*