Sunday, January 8, 2012

Text-to-Path Conversion with Ghostscript

So you’ve prepared some PDF material with LaTeX, which you’re going to send to the printing company.

If they’ using the PDF as it is, fine and dandy. But if they need to import the PDF into, say, Illustrator for some further processing, you might be in some kind of a fix if the fonts you used (in LaTeX) aren’t easily obtainable as TTF OTF forms.

One solution is to convert all texts into paths before submitting the PDF to the printers. I don’t have Illustrator, so I tried Inkscape instead. Now Inkscape does have a convert-text-to-path function, but for the texts to display properly in Inkscape in the first place, I’d still need the TTF OTF files. Inkscape cannot make use of fonts embedded in the PDF to import the text as paths directly. Not very helpful, then.

Fortunately, suv gave this workaround using Ghostscript:

As a workaround, you can use Ghostscript to convert text in a PDF (or EPS/PS) file to outlines. It requires to convert the PDF to an intermediary PS file, and then back to PDF (thus losing PDF features not supported by PostScript, like transparency).
E.g. use a shell script, containing a command similar to this one:

\$ gs -sDEVICE=pswrite -dNOCACHE \
-sOutputFile=- -q -dbatch -dNOPAUSE \
-dQUIET "\$1" -c quit | ps2pdf - \
"`echo \$1 | cut -f1 -d'.'`"-nofont.pdf

So long as your file does not contain any transparency, the script works just fine, and you can submit the file*-nofont.pdf to your printer. And of course, expect some increase in file size.

1 comment:

1. One can use pstoedit, also.

And, sometimes, adding resolution (-r300 or -r600) helps to solve problems…