This days I had to send a multiple page PDF with a bunch of pictures on it, but requirements said that it needed to be smaller than 5Mb. With Ghostscript I was able to transform a 10.9MB file into a 1.2Mb without loosing quality, since it was mandatory that the small letters contained on the PDF were completely readable.

To work with ghostscript first you need to install it:

[tatica@libro ]$ sudo su –

[root@libro ]$ dnf -y install ghostscript

Then we exit the root mode and locate at the folder where we have the file, in my case:

[root@libro ]$ exit

[tatica@libro ]$ cd /home/tatica/Documentos/archivo-maestro.pdf

To run ghostscript let me first explain you the options you can choose, and what you can archive with each one of them:

/prepress (default) Higher quality output (300 dpi) but bigger size

/ebook Medium quality output (150 dpi) with moderate output file size

/screen Lower quality output (72 dpi) but smallest possible output file size

In my case, I want the file to be compress, but not to loose quality, so I ran my script with the ebook option:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQU
IET -dBATCH -sOutputFile=archivo-resultante.pdf archivo-maestro.pdf

and that’s it. Remember that the output file comes first, and the file you want to convert comes at last (I know, tricky). If you used it, let me know how did that work for you!


This post has a nicer formatting that can be seen at it's original source at tatica.org , so feel free to hit the link and read better version!