Classical Guitar Humor Recipes Tech Stuff Web Log
The Sergents

Making PDFs smaller with Ghostscript

Thu Jul 30, 2009
Often I find myself sending PDF documents around that have been generated from OS X using its print to PDF functionality or scanned in from the old HP all-in-one. Handy! Works great! Except for the fact that the files generated tend to be on the largish side.
To get around this I found some helpful commands for Ghostscript that can shrink said largish PDF down to a more reasonable size. To be honest I'm not sure of any negative side effects, but this has saved me on several occasions.

Here is the function I made in my .bash_proflie (no real error checking and only does one file at a time)
1
2
3
4
function shrinkpdf {
    mv "${1}" "${1}.tmp" && gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH \
	-dPDFSETTINGS=/ebook -sOutputFile="${1}" "${1}.tmp" && rm "${1}.tmp"
}

Here is an example from a recently scanned document
Before shrinking 7.7M 8057822 Jul 14 15:45 sc0070af27.pdf
Then ran:
shrinkpdf sc0070af27.pdf
After shrinking 1.2M 1294394 Jul 30 07:15 sc0070af27.pdf

Saving some space! Not a big deal in the grand scheme of things, but helps when it is necessary to send multiple documents while staying below the 10M cap that many email servers still have as a limit. Could be improved greatly, but like many things it worked and that's all it takes to GTD.

Comments:

Dana Sergent
2 years, 4 months ago...
(Fri Oct 09, 2009)

Well, I installed Snow Leopard recently and it appears that the scanning has been greatly improved. That is if you can get your HP scanner to work right off the bat, but that's another story.

From what I've seen scanning in black and white produces pdf documents similar in size to what I was getting shrinking with ghostscript. One more thing I might not have to worry about right now. Good to have in the tool in the toolbox just in case.

Mike Landl
2 years ago...
(Fri Jan 29, 2010)

Great tip, thanks!

Leave a comment:

Name and Email required. Url not required. Email will not be displayed publicly.

Almost all entries are set to moderated, so your comment might not display immediately.

.
Home Site Index About Contact Some rights reserved
©2012