Ubuntu Tip:Howto reduce PDF file size from command line

If you want to reduce PDF file size using command line you can use ghostscript.Ghostscript is used for PostScript/PDF preview and printing. Usually as a back-end to a program such as ghostview, it can display PostScript and PDF documents in an X11 environment.

Furthermore, it can render PostScript and PDF files as graphics to be printed on non-PostScript printers. Supported printers include common dot-matrix, inkjet and laser models.

Package gsfonts contains a set of standard fonts for Ghostscript.

Use the following command syntax to reduce your pdf files

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

Replace your file names output.pdf,input.pdf files with your file names.

This is only example you can check man gs command for more options.

If you want to install ghostscript use the following command

sudo apt-get install ghostscript

Sponsored Link

You may also like...

43 Responses

  1. inem says:

    U’re Genius ^_^

  2. Dan says:


  3. BH says:

    Thank you very much!!!!! Another reason why I love Linux so much – you can do anything! 🙂

  4. Zapp says:


  5. vincenzo says:

    thank you – exactly what I needed!!!

  6. Boris says:

    Thanks, here’s a bitcookie 8635 for you.

  7. zigeuner says:

    you totally rock, thank you

  8. Rostin says:

    I just used Libreoffice 4.0 Draw to open the document and chose PRINT TO PDF to choose the resolution and quality percentage I needed. Adjust those settings to get it down to the size you require (without sacrificing quality too much of course).

  9. fstephens says:

    Thanks! Reduced a 25MB pdf to 1.5MB! Quality OK.
    This was a PDF created from an image file with ImageMagick’s convert command. Probably it could be used to directly reduce filesize, but I didn’t see that option.

  10. ubundom says:

    36.3MB –> 618.2kB


  11. Jingpeng says:

    Thanks, 94MB to 1.4 MB!

  12. bojan says:

    2.2MB-> 2.0MB

  13. alex says:

    Please note that this command won’t work fine with fillable PDFs.

Leave a Reply

Your email address will not be published. Required fields are marked *