Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Ghostscript to use embedded fonts in PDF

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.

like image 615
Sheldon Ross Avatar asked Apr 19 '10 20:04

Sheldon Ross


People also ask

How do I make sure fonts are embedded in a PDF?

To embed the fonts that are not already embedded, go to File > Print. Bring up the Adobe PDF settings and properties, then Adobe PDF settings. Embed your font. Edit the default settings and navigate to Font, click the Embed all fonts option.

Can you edit embedded fonts on PDF?

Font embedding is done for one reason only: To allow you to display/print the document without the font in question having to be available on the computer or the printer that is used to output the PDF document. It does not allow you to edit the text in the PDF document.

How do I fix font is not embedded?

Go to Tools > Print Production > Preflight select the “PDF fixups” option and select “Embed missing fonts” and click the “Analyze and fix” button to embed any unembedded fonts. After clicking Analyze and fix, you will be asked to save your new PDF document. Save it with the name and location you like.


1 Answers

Embedding fonts retroactively 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 "<</NeverEmbed [ ]>> setdistillerparams" \
   -f input.pdf
like image 144
Kurt Pfeifle Avatar answered Sep 22 '22 15:09

Kurt Pfeifle