tags:

views:

279

answers:

1

Hi everyone, we have a lot of print ready PDFs that we want to downsample to a smaller size that are suitable for online downloads. I am using GhostScript like this:

"C:\Program Files\gs\gs8.64\bin\gswin32c.exe" -q -dNOPAUSE -dBATCH -dSAFER -dPDFSETTINGS=/screen -sDEVICE=pdfwrite -sOutputFile="c:\gs_out.pdf" -f "c:\6916_DE.pdf"

The problem is that GhostScript is failing to convert one image so when I am opening the resulting PDF Adobe Reader warns me about a possible error in the file. If i change the PDFSETTINGS parameter to /print the output works but the filesize is not reduced.

I have read the help file for ps2pdf and I have found one critical parameter, ColorConversionStrategy. When ColorConversionStrategy is set to sRGB the image will be removed, when set to UseDeviceIndependentColor, which is the default for the /print setting, the image is still there but the file size is not reduced.

The image is transparent so that might be one factor aswell.

Anyone got any ideas?

A: 

First, I would suggest you update your Ghostscript to the latest version, which is v8.71. A lot of problems regarding PDF processing have been fixed since 8.64 (which you seem to use).

Second, if you use -dPDFSETTINGS=/screen on your commandline, this will implicitly also set:
-dColorConversionStrategy=/sRGB and
-dColorImageResolution=72.
But -dPDFSETTINGS=/printer implicitely uses:
-dColorConversionStrategy=/UseDeviceIndependentColor as well as
-dColorImageResolution=300.

If your main goal is to reduce the image size, try this:

gswin32c.exe ^
   -o c:\gs_out.pdf ^
   -sDEVICE=pdfwrite ^
   -dPDFSETTINGS=/screen ^
   -c ".setpdfwrite" ^
   -c "<</ColorConversionStrategy /LeaveColorUnchanged>> setdistillerparams" ^
   -c "<</ColorImageDownsampleType /Bicubic>> setdistillerparams" ^
   -f "c:\6916_DE.pdf"

You continue to use /screen (and therefor you imply -dColorImageResolution=72).

However the two -c parameters will override two other implied /screen settings. This could possibly overcome your problem.

pipitas

related questions