The other day I downloaded a PDF that ended up being a whole lot bigger than I thought. A “whopping” 230MB, which is another deal compared to the 30MB PDF’s that I’m accustomed to. So how to reduce the file-size? Ghostscript to the rescue!
If you have Ghostscript installed, run the following command to reduce the file-size of your PDF:
1 |
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -sOutputFile=new_file.pdf original_file.pdf |
Now you have a few options here under -dPDFSettings:
- /screen selects low-resolution output, and the lowest file-size.
- /ebook selects medium-resolution output, with a medium file-size.
- /printer and /prepress are both the high-resolution options, which is mainly used for printing PDFs. As you might have guessed, this option gives you the biggest file-size (yes, even bigger than your mother).
The results?
1 2 3 |
[jorge@(ashitaka):~/Downloads/PDF] du -h * 29M new_file.pdf 230M original_file.pdf |
What can I say. I’m a cheap bastard when it comes to storage space, no matter how low the price might be. ;)
The author should add that it takes a lot of time (and considerable CPU resource) to perform this task. After the 4th minute with the ‘screen’ option I gave up…(
Mine took about 10 seconds. Your PC must be slow or something.
Reading my comment again after two years, I can safely say that it was overly aggressive and rude. I have noticed the slowing down of conversion for large pdf files on my own machine, so I was stupid back then :-)
Compressing large files often take a lot of time. I compressed a 572 pages PDF file, it took me several dozens of minutes, but it was worth it. I can now browse it fluidly.
This and pdftk are amazing for handling my college notes.
Thanks bro. It reduced my pdf file size from 244Kb to 68Kb… 1/4 of original
Pingback: Reduzindo o tamanho de um arquivo PDF | Admirável Trivialidade Nova
Thanks for the tip.
Exelent, thanks, working fine, great job
Thanks bro.
Awsome. Thanks!
Really great tip! Thanks!
I used it to reduce the size of pages I scanned with xsane.
The reduction in file size is dramatic while the results look really good!
Excellent information. Thank you so much
Amazing, I turned a 42MB PDF into a 2.4MB PDF
Thanks! ;)
Pingback: Helping a friend | nochkawtf
Pingback: Bookmarks for 22 mag 2015 through 29 mag 2015 | jtheo
This is working just fine.
Thank you very much.
How can I compress multiple files at same time
To compress multiple files, you could try something like:
for i in *.pdf; do "gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -sOutputFile=new_$i $i"; done
This will compress all of the PDF-files in the directory you’re currently in.
What’s dCompatibilityLevel? Is this the Adobe PDF version? If so, 1.4 would result in fragmented images. v1.6 is the “digital standard”.