You can use Ghostscript to achieve this. You need to follow 2 steps:
Convert a PDF to a PostScript file in which all the fonts used are converted to outline shapes. The key here is the -dNOCACHE
paragraph:
gs -o somepdf.ps -dNOCACHE -sDEVICE = pswrite somepdf.pdf
Convert the PS back to PDF (and possibly delete the intermediate PS again):
gs -o somepdf-with-outlines.pdf -sDEVICE = pdfwrite somepdf.ps
rm somepdf.ps
Please note that the resulting PDF is likely to be larger than the original. (And without additional command-line options, all images in the original PDF file will most likely also be converted according to the default Ghostscript settings, unless you add more command-line options to do otherwise. But the quality should be better than your own attempt to use ghostscript ...)
Update
Apparently, from version 9.15 (will be released in September / October 2014) Ghostscript will support the new command line parameter :
-dNoOutputFonts
which will cause the output devices pdfwrite
, ps2write
and eps2write
βsmooth outβ the glyphs into the βbasicβ marking operations (instead of writing the fonts in the output). "
This means that the above two steps can be avoided, and the desired result will be achieved with a single command:
gs -o somepdf-with-outlines.pdf -dNoOutputFonts -sDEVICE=pdfwrite somepdf.pdf
Caveats: I tested this with multiple input files using self-compiled Ghostscript based on current Git sources. In each case, it worked flawlessly.
source share