My PDF concatenation page is quite popular, and I recently had occasion (while publishing a book through Lulu) to need a couple of other hard-to-find Postscript and PDF-related techniques, so I'm recording them here in case they're useful to others.
If you attempt to convert a raster image into a PDF (for instance, to use as a book cover) using pnmtops followed by epstopdf, you will find that it gets compressed with "DCTEncode", which is basically the same thing as JPEG. That's a lossy compression scheme, and it produces artifacts that look like JPEG artifacts, especially annoying if your image contains sharp-edged text. These kinds of artifacts would be prohibitive if, for instance, you were trying to make a bar code label for a Lulu book. Other free PDF-producing software (for instant, ps2pdf) is likely to have the same problem because they almost all use Ghostscript for the PDF-generating back end.
You can set the compression using poorly documented Ghostscript options. The ones that work for me are "-dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode". With epstopdf, there's no way I could find to specify those on the command line, so I set the GS_OPTIONS environment variable to contain that value. Another possibility would be to use "/LZWEncode" instead of "/FlateEncode"; both are lossless, LZW may give better compression, but there were formerly patent issues with LZW. The patents on it are expired now, but many installations of Ghostscript date from before the expiry of the patents and will either fail, substitute Flate, or do no compression if LZW is requested. "Flate" has problems too: it is a Level 3 Postscript feature and may harm compatibility if you use it in Postscript as opposed to PDF, but as far as I can tell, support for it is required in PDF so you shouldn't have a problem using it for the purpose I'm suggesting. Note: the posting at the bottom of this page on the Lulu support Web BBS seems to indicate that Flate may be preferable to LZW for files submitted to them.
This command renders the Postscript file input.ps into a PPM image with a resolution of 600dpi, which it spits out on standard output for you to pipe into other software. You want "ppmraw" instead of "ppm" because "ppm" is the ASCII version of the PPM format, and elephantine in size. The "< /dev/null" is needed to prevent Ghostscript from prompting you for interactive commands; there may be a more elegant way to do that. Changing the resolution, of course, just means changing the "-r600" option to whatever resolution you want. This command runs without anti-aliasing. I'm still looking for a way to turn on anti-aliasing in Ghostscript. For the moment, I'm faking it by rendering at a higher resolution than I want and then scaling down.
gs -sDEVICE=ppmraw -q -sOutputFile=- -r600 input.ps < /dev/null
To put all fonts in your PDF in as compatible a form as possible, use the options "-dSubsetFonts=false -dEmbedAllFonts=true" (with ps2pdf or any other Ghostscript-based PDF generator). Be warned that that will include the entirety of every font you use, in the document, in a form that allows whoever gets the document to use the font. That is, of course, the point; but it has implications for, and may be prohibited by, the copyright licensing on many fonts.
mihai from 134.76.153.125 at Wed, 30 Jan 2008 20:18:11 +0000:
Hey! I searched a while for a command option in epstopdf to disable lossy compression (for pdflatex), but found none. It's possible to add your suggested GS_OPTIONS in epstopdf itself by changing line 157 (after "### option compress") to something like
$GSOPTS = "-dUseFlateCompression=false -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode " unless $::opt_compress;
which is then used when epstopdf is called with --nocompress
Not sure If that doesn't break something, but works well for me. Thanks a lot!
LozzaK from 137.222.184.160 at Fri, 15 May 2009 12:26:13 +0000:
You are a genius! I was having problems with ugly compression stuff and this sorted it right out. It worked for me in GSView for converting PS to PDF and it also worked right inside the TeXnicCenter environment I was using to write my thesis. I just added the -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode arguments into the arguments passed to the GSView(ps2pdf) postprocessor and the PDF was much better in the JPEG-type (i.e. photo-type) images in the document. The document was about 5 times the size, but much better quality! :)
xanderp123 from 69.196.137.29 at Sat, 27 Mar 2010 17:59:00 +0000:
Thank you very much for this tip!
I went to Staples 24 Hour Copy and Print Centre to get my undergraduate thesis printed this morning. Although they accept over 200 file formats, PostScript is not one of them! I couldn't believe it. I went home and converted my PostScript file to PDF using ps2pdf and found that some of my figures looked horrible. However, your solution fixed the problem and now my PDF file looks as good as the original PostScript file. Thanks.
timjowers from 74.245.83.62 at Wed, 03 Jan 2007 02:49:09 +0000:
Thanks!
My process was to install a printer driver for a B&W printer and select that and then click a checkbox to print to a file. I had to do this as I could not get ps2pdf to convert color images to grayscale. Then I convert the Postscript file to PDF for LuLu using:
ps2pdf14 -dSubsetFonts=false -dEmbedAllFonts=true OpenSourcePro-Joomla.ps OpenSourcePro-Joomla3.pdf
Using plain ps2pdf fails to embed the fonts according to LuLu.com Press.
My upload time is about 6 minutes for an 18M file. Since I'm back for 512Mb/s upload then I should be about to get around 3 MB/s. Looks like BellSouth is solidly enforcing the upload speed limit. In a case like this it really feels slow!
What is funny is LuLu.com Press has not bothered to document a solution for Linux; tjhey give this message with a link but no good documentation behind the link:
our document could not be created: Font "Helvetica" is not embedded. (How do I embed fonts?)
Cheers,
TimJowers