A scanned document saved as PDF can be too large, that is not always good.
For example, the large size of a PDF file won’t permit to send it by email because of the probable limitation on the maximum size of attachments.
In Linux you can compress a PDF file from the command line without losing its quality, with the help of
ps2pdf tool, that is a part of
From this article you will learn how to compress a PDF file and significantly reduce its size from the Linux command line.
Cool Tip: Plan to send this PDF somewhere or just keep? How about to protect it with a password? This is really easy for ones who reduce the size of a PDF file from the command line! Read more →
First of all it is required to install the
ghostscript suite that provides the
$ sudo apt-get install ghostscript
Compress PDF File In Linux
Run the following command to compress and reduce the size of the
LARGE.pdf file and save the result to the
$ ps2pdf LARGE.pdf SMALL.pdf
Effectiveness is obvious:
$ du -sh *.pdf 7,6M LARGE.pdf 500K SMALL.pdf
You can also add this command to reduces the size of a PDF file:
$ gs -sDEVICE=pdfwrite \ -dCompatibilityLevel=1.4 \ -dDownsampleColorImages=true \ -dColorImageResolution=150 \ -dNOPAUSE \ -dBATCH \ -sOutputFile=OUTPUT.pdf INPUT.pdf
27 Replies to “Linux: Compress PDF – Reduce PDF Size”
Thank you very much for your hack! It worked like a charm and I did learn something new.
Exactly what I needed too. Thank you.
Great “hack”. Compressed my PDF from 12,6 MB to 12,5 MB….
wonderful: from 900.5 to 901.9. This is exactly what I was looking for! You made my day!
Thank you for this! On average, my pdf files are being reduced to half their original size.
Nonsense. This created a larger file.
The real great hack! Have 1.5GB pdf after processing some pages, this stuff gives me a 6MB file. WOW! Want know, why.
nothing happens, same file size
For those who complain it doesn’t work make try another file. Perhaps the file you’re trying to compress is the smallest size possible and cannot be further compressed
Converted a test file from 876k to 128k. I have hundreds of files and I can save a lot of space by running this on them. Thanks!
It is impossible to reduce the size without affecting the quality, the total size of the PDF produced is lower than the size of one of the 30 images included in it.
Camooon, its not fair!!! Wish i knew it before……… from 29M to 3.7m
20 MB -> 2 MB for me. Looks like this works for huge files. Not for those, that are already reasonably-sized.
I used pdfunite to merge some pdfs and the result was a 295MB file, it went down to 16.5MB with ps2pdf. Thank you so much bro!
Fantastic! Totally grateful for this : )
I tried to use such technic, but it doesn`t work. I also attend to convert my file from pdf to djvu. It dicreased in size approximately two times, but work sighnificuntly quickly because djvu is better for scanned big-size file.
Thanks, you save my day !!!
Thanks, this comment is more helpful than the content of the webpage 😀
Yes, this one works better for pdf with scanned images
useful option for 150ppi all images
A very elegant piece of code that did a wonderful job for me. Thank you!
didn’t work for me. I made a 74.6MB pdf from hundreds of images and it remained same as before. maybe the images can’t be compressed any more.
Wow, that;s effective
Amazing article! This tool (ps2pdf) worked flawlessly for me! Thx!
Thank you very much. From 7.6 MB to 757.3 kB
From 67 MB to 9.9 MB. Thanks for this ShellHack!
The guys that had a bigger file maybe lower resolution at `ColorImageResolution` parameter.
I tested 75 DPI in place of 150 DPI, the file went to 4.2 MB but the images were bad.