Sunday, December 09, 2007

high quality eps in pdf

From http://electron.mit.edu/~gsteele/pdf/

One of the problems with pdf conversion is that most pdf converters
("distillers") are configured by default to always use lossy (DCT
Encoding) for color and grayscale images. For a scientific paper, this
produces very poor results. In order to get high quality figures in
the converted PDF, you can either tell the PDF distiller to use
FlateEncode or to use DCTEncode with a high quality factor. Here are
the postscript snippets that allow you to do this:

* Use DCTEncode with a high quality factor: this involves setting
a parameter called "/Qfactor" to a small number. The /Qfactor
parameter actually refers to "Quantization factor". Setting this to
0.15 uses the same settings as "Maximum Quality" mode for Acrobat
distiller.

systemdict /setdistillerparams known {
<< /ColorACSImageDict << /QFactor 0.15 /Blend 1 /ColorTransform
1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >>
>> setdistillerparams
} if

* Use FlateEncode: this way, the images that you see in the
converted pdf file will be exactly identical to the EPS images you
submit.

systemdict /setdistillerparams known {
<< /AutoFilterColorImages false /ColorImageFilter /FlateEncode
>> setdistillerparams
} if

To use these, simply open up your .eps file in a text editor such as
emacs and insert the text after the end of the "%" commented area at
the beginning of the file. This should automatically work with dvipdfm
conversion as well as the pdf conversion software used on the arXiv
server.

2 comments:

rfabbri said...

I use the second option most often with dvipdfm. Here is how the beginning of my eps file looks like after the code insersion:

%!PS-Adobe-3.0 EPSF-3.0
%%Creator: (ImageMagick)
%%Title: (myimage.eps)
%%CreationDate: (Wed Feb 13 11:36:51 2008)
%%BoundingBox: 0 0 366 212
%%HiResBoundingBox: 0 0 366.03 212
%%DocumentData: Clean7Bit
%%LanguageLevel: 1
%%Pages: 1
%%EndComments

%%BeginDefaults
%%EndDefaults

%%BeginProlog

systemdict /setdistillerparams known {
<< /AutoFilterColorImages false /ColorImageFilter /FlateEncode
>> setdistillerparams
} if

rfabbri said...

One more note.

If you want to make your final .pdf latex paper as *small* as possible, one mode of action is to try out different ways to convert a .dvi to .pdf. I've noticed that dvipdfm currently produces much larger files than dvips + ps2pdf. This last option works well for me when size is of the essence.