Reputation: 427
Need a Java-based solution or, at the worst, command-line for Linux.
I tried to use Ghostscript:
gs -sDEVICE=pdfwrite -dPDFA -dBATCH -dNOPAUSE -dUseCIEColor \
-sProcessColorModel=DeviceCMYK -sPDFACompatibilityPolicy=1 \
-sOutputFile=downgraded.pdf leon_range_my12_w22_brochure.pdf
but I got a lot of errors...
Upvotes: 36
Views: 15886
Reputation: 39
I tested today, that for some reason Ghostscript (9.54.0) -dPDFSETTINGS=/screen
will automatically increase the filesize, if the image resolution is set to 70 dpi or higher. If the dpi value is set just below 70, it will operate really well and create practically screen quality document in significantly smaller filesize, keeping all vector based fonts intact. Here is my command line that really squeezes the air out of the massive PDF:s.
gswin64.exe -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dBATCH -dQUIET -dDownsampleColorImages=true -dColorImageResolution=69 -dColorImageDownsampleType=/Bicubic -dAutoFilterColorImages=false -sOutputFile=YourOutputFile YourInputFile.pdf
Upvotes: 1
Reputation: 90285
Here's an example of how you can downsample all (color, gray and mono) images to 72dpi with a Ghostscript commandline:
gs \
-o downsampled.pdf \
-sDEVICE=pdfwrite \
-dDownsampleColorImages=true \
-dDownsampleGrayImages=true \
-dDownsampleMonoImages=true \
-dColorImageResolution=72 \
-dGrayImageResolution=72 \
-dMonoImageResolution=72 \
-dColorImageDownsampleThreshold=1.0 \
-dGrayImageDownsampleThreshold=1.0 \
-dMonoImageDownsampleThreshold=1.0 \
input.pdf
Update:
The *ImageDownsampleThreshold=1.0
parameters enforce that all Images with a resolution higher than the target resolution of 72 dpi will be downsampled. If this parameter is not given (or set to a different value), the default values will be used: *ImageDownsampleThreshold=1.5
. This default value will only downsample images with a value of 108 dpi (or higher) and leave the other ones untouched.
Upvotes: 61
Reputation: 21
For a scanned document in which each page is a full color image, I used a combination of the command line above and another that I found on a different site,
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dDownsampleColorImages=true \
-dColorImageResolution=150 -dNOPAUSE -dBATCH -sOutputFile=output.pdf input.pdf
Each of my pages was a color scan of a document. This command line reduced the resolution of the pages to 150dpi, cutting the file size in half without significant loss of resolution. It's still looks good and the text is comfortably readable on my Nexus 7.
Upvotes: 2
Reputation: 8576
This is what I am using:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=OUTPUT.pdf INPUT.pdf
For your reference:
-dPDFSETTINGS=/screen (screen-view-only quality, 72 dpi images)
-dPDFSETTINGS=/ebook (low quality, 150 dpi images)
-dPDFSETTINGS=/printer (high quality, 300 dpi images)
-dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs)
-dPDFSETTINGS=/default (almost identical to /screen)
Upvotes: 17