How to get Ghostscript to use embedded fonts in PDF

Sheldon Ross picture Sheldon Ross · Apr 19, 2010 · Viewed 17k times · Source
gs -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dBATCH \
   -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf

I'm using (trying anyway) to use Ghostscript to reduce my PDF file size. The command above looks like it works, it reduces file size greatly, but then several of the fields are garbled. As for as I can track it down, It's doing font substitution. IE, The same text = same garbled text.

The fonts are embedded in the PDF when it gets to me. Additionally, I have tried to add all the fonts to the Fontmap.

Any ideas, Ideally I would like it to use the embedded fonts without me having to update the gs system fonts/edit fontmap, etc. I'm using Ubuntu 9.10 and the Fonts embedded are windows fonts, Arial/TimesNewRoman.

Thanks.

Answer

Kurt Pfeifle picture Kurt Pfeifle · Jun 5, 2010

Embedding fonts retrospectivly which were not embedded in the original PDF does increase the file size, not decrease it.

However, there may still be a chance to reduce the overall file size by reducing the resolution of embedded images... depends on your preferences and needs.

You can try with variations of the following commandline. It will embed all fonts (even the "Base 14" ones), but embed required glyphs only (a "subset" of the original font), and also compress the fonts:

gs \
   -dCompatibilityLevel=1.4 \
   -dPDFSETTINGS=/screen \
   -dCompressFonts=true \
   -dSubsetFonts=true \
   -dNOPAUSE \
   -dBATCH \
   -sDEVICE=pdfwrite \
   -sOutputFile=output.pdf \
   -c ".setpdfwrite <</NeverEmbed [ ]>> setdistillerparams" \
   -f input.pdf