Ghostscript PDF batch compression

Viewed 26250

I've installed Ghostscript on Windows as what I'm looking to do is compress/reduce the size of 12,000+ PDF files on a network share. This wouldn't be possible with any GUI software as it just bombs out after a while due to running out of resources, so I think command line is the way to go here.

I've read the Ghostscript documentation and different examples of compressing PDF files, but I can't seem to find anything that operates as a large batch.

Basically, I'd need to target multiple folders to recursively compress the files which will be on the network share.

Is this possible to do so with Ghostscript? If so, please advise with some command examples to help me acheive this.

Thanks!

4 Answers

I don't know if anyone need it, but here's my command to highly compress PDF files with no degradation of quality. I've found it by method of many trials and errors an it's greatly reduce PDF files size. P.S. Sorry for posting not in the above thread, but I don't enough reputation for it as a newcomer.

%ghostscript% -q -dNOPAUSE -dBATCH -dSAFER -dSimulateOverprint=true -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -dEmbedAllFonts=true -dSubsetFonts=true -dAutoRotatePages=/None -dColorImageDownsampleType=/Bicubic -dColorImageResolution=150 -dGrayImageDownsampleType=/Bicubic -dGrayImageResolution=150 -dMonoImageDownsampleType=/Bicubic -dMonoImageResolution=150 -sOutputFile=output.pdf input.pdf

I was facing the same issue this helped me. converted 15 MB pdf into 400kb

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.2 -r200 -dPrinted=false -dNOPAUSE -dQUIET -dBATCH -sOutputFile=c12_{filename} {filename} 

nothing here worked with latest gs, so I ended up with

gswin64c.exe -dPDFSETTINGS#/ebook -dPDFX -dBATCH -dNOPAUSE -sColorConversionStrategy=CMYK -sDEVICE=pdfwrite -sOutputFile="output.pdf" "input.pdf"

And with autosize form jpg and rotation 90 degrees clockwise

gswin64c -dORIENT1=false -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=C:\Users\username\Desktop\somepdffile.pdf -c "<</Orientation 3>> setpagedevice" -f "C:\Program Files\gs\gs9.19\lib\viewjpeg.ps" -c "(C:\\Users\\username\\Desktop\\somejpgfile.JPG) << /PageSize 2 index viewJPEGgetsize 2 array astore  >> setpagedevice viewJPEG"

/Orientation 3 controls rotation angle

Related