views:

305

answers:

1

We're currently using ps2pdf to convert EPS files to PDF. These EPS files contain both vector information (lines and text) and bitmap data.

However, by default ps2pdf converts the bitmap components of these images to JPG as they're embedded within the PDF, whereas for the type of graphics we have (data visualisation) it would be much more appropriate to use lossless compression. PDF supports PNG, so it should be possible to achieve what we're trying to do, but I'm having trouble finding a relevant option in the somewhat intimidating manual.

So the short question is: what is the correct way to write this?

    ps2pdf -dPDFSETTINGS=UsePNGinsteadOfJPGcompression input.eps output.pdf

+1  A: 

The answer is not -dUseFlateCompression, since that option refers to using Flate instead of LZW compression; both are lossless but LZW was covered by patents for a while. Since that's not a problem any more, the option is ignored.

Instead, the options called to achieve lossless encoding of bitmap data are: (all four of)

  -dAutoFilterColorImages=false 
  -dAutoFilterGrayImages=false 
  -dColorImageFilter=/FlateEncode 
  -dGrayImageFilter=/FlateEncode

You might also want to do the same thing with MonoImageFilter as well, but I assume /CCITTFaxEncode does a reasonable job there so it's not too important.

Will Robertson
You are right. I just realized, however, that the `ps2pdf` I have on my system (part of MikTeX's ghostscript) seemed to "do the right thing" no matter what I specified on the command line. I guess that. combined with insufficient testing, led me into thinking that `-dUseFlateCompression` was doing something.
Sinan Ünür
Cheers, no worries. The lossy encoding can be pretty subtle to spot at the quality that ps2pdf applies by default.
Will Robertson