I need to generate JPEG's from PDF. JPEG must be created based on Trim Box and PDF's can be version 1.3 with extra Pantone colors that absolutely require Overprint Preview so only GhostScript (and Rip's of course can handle them). Both Photoshop, Image Magick and SIPS (Scriptable Image Processing System of OS X) cannot solve both problems (Crop to trim and composite handling overprint).
I created an app to rasterize the PDF I receive and all works good EXCEPT that some chinese PDF have one font not embedded. This font is Chinese STXiHei TrueType (CID) with encoding G8pc-EUC-H (info extracted form Acrobat Pro).
Now when GhostScript process these PDF goes in error. My question are:
- Because the not embedded font is outside the TrimBox region, there is a GS parameter that permit to skip not embedded font?
- If point 1 is not possible how is possible to substitute the missing font?
- My Installation of GS 9.02 on OS X don't install cidfmap file nor fonts folders.
- What I need to install and where in order to use substitute fonts?
- I read many times the use.htm and spent some days of testing all without success trying to ignore or substitute the not embedded font with another. The argument seems complex, but probably the solution is simple.
Somebody can help me?
This was (eventually) answered where it started, on UseNet in comp.text.pdf. The problem is that the PDF file contains a reference to a CIDFont (not a font, a CIDFont). Contrary to the problem statement above the font is not embedded, and this is the difficulty.
CIDFonts are rather more complex than fonts, and it is not simple to substitute for missing fonts in the same way as missing Latin regular fonts are substituted with (for example) Courier.
It isn't possible to skip the font because Ghostscript can't know immediately where the text is going to be rendered (ie the font is loaded before we find out where the text is going to be drawn).
Now Ghostscript does allow you to specify additional fonts; in the case of CIDFonts these are described in the file called cidfmap which is located in gs/Resource/Init in the Ghostscript distribution.
Problem 1 is that by default GS has its resources built into the executable, and uses the file located in the ROM file system. So we need to tell GS to look on disk instead. There are two ways to do this:
1) Copy all the resources from the source distribution (everything under /gs/Resource) to a convenient location and use the -sGenericResourceDir= switch to tell GS to use this directory. If you do this then you must be careful to add a trailing directory separator to the end of the path. I mention this because normally with GS you don't do that. In this case the PLRM says we must.
2) Copy the cidfmap file somewhere convenient and tell GS to look in that directory by using the -I switch which adds the directory to the head of the search list. Its important that its the head, because you can only have one cidfmap file, and GS uses the first one it finds.
So, on to the font files themselves. You can either use a genuine CIDFont, or you can use a TrueType font as a substitute for a CIDFont.
If you use a genuine CIDFont then you must either use option 1 above (GenericResourceDir) and put the file in a directory named Resource/CIDFonts under the location of GenericResourceDir or you use option 2 and put the CIDFont in a directory named CIDFonts directly under the location pointed to by -I.
If you use a TrueType font as a substitute then you can use the /Path key in the entry for the font in cidfmap to point to the TrueType font.
The complexities of converting a TrueType font of unknown provenance into a specific type of CIDFont mean that you have to supply a lot of information in the cidfmap entry, this is documented in the file itself. Things to watch out for:
1) The /Path must point to the font file, it must be present and have permissions allowing it to be read.
2) You should supply a /SubfontID for a TrueType Collection. If you want to use anything except the first subfont then you must supply a SubfontID.
3) The entries in cidfmap are interpreted by a PostScript interpreter and so must conform to PostScript syntax. In particular the font name is a PostScript name object and so must be introduced with a '/'.
Finally; a number of Linux distributions do not ship the full source for Ghostscript, you may need to pick this up before using any of the advice above. You can get releases from here:
来源:https://stackoverflow.com/questions/6643817/rasterize-pdfs-with-font-not-embedded-using-ghostscript