使用不使用GhostScript嵌入的字体栅格化PDF [英] Rasterize PDF's with font not embedded using GhostScript

查看:763
本文介绍了使用不使用GhostScript嵌入的字体栅格化PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从PDF生成JPEG。 JPEG必须基于Trim Box创建,而PDF的版本可以是1.3版本,并且需要额外的Pantone颜色,因此绝对需要叠印预览,因此只有GhostScript(和Rip当然可以处理它们)。 Photoshop,Image Magick和SIPS(OS X的脚本化图像处理系统)无法解决这两个问题(裁切裁切和复合处理叠印)。

我创建了一个应用程序栅格化我收到的PDF,并且一切正常,除了一些中文PDF有一个没有嵌入的字体。这个字体是中文STXiHei TrueType(CID),编码为G8pc-EUC-H(从Acrobat Pro提取的信息)。

现在当GhostScript处理这些PDF时出错了。
我的问题是:


  1. 因为没有嵌入的字体在TrimBox区域之外,所以有一个GS参数允许跳过不是嵌入的字体?
  2. 如果不可能用点1代替丢失的字体

  3. 我在OS X上安装GS 9.02安装cidfmap文件和字体文件夹。
  4. 我需要安装什么以及在哪里才能使用替代字体?
  5. 我读了很多次use.htm,花了几天的测试都没有成功,试图忽略或替换不嵌入字体与另一个。这个论点似乎很复杂,但可能解决方案很简单。

有人可以帮我吗?

这个(最终)是在comp.text.pdf的UseNet上开始的。
问题是PDF文件包含对CIDFont(不是字体,CIDFont)的引用。与上面的问题相反,字体不是嵌入式的,这就是困难。



CIDF字体比字体要复杂得多,并不是简单地用缺失的字体来替代丢失的字体,而是使用(例如)Courier代替缺少的拉丁字体。



不能跳过字体因为Ghostscript无法立即知道文本将要呈现的位置(即,在我们找到文本将要绘制的位置之前加载字体)。

现在Ghostscript可以让你指定额外的字体;在CIDFonts的情况下,这些被描述在名为cidfmap的文件中,该文件位于Ghostscript发行版的gs / Resource / Init中。

问题1是默认的GS其内置到可执行文件中的资源,并使用位于ROM文件系统中的文件。所以我们需要告诉GS来看看磁盘。有两种方法可以做到这一点:$ b​​
$ 1)将所有资源从源代码分发(位于/ gs / Resource下的所有东西)复制到一个方便的位置,并使用-sGenericResourceDir =切换到告诉GS使用这个目录。如果你这样做,那么你必须小心地将尾随目录分隔符添加到路径的末尾。我提到这一点,因为通常GS不会 那样做。在这种情况下,PLRM说我们必须。2)复制cidfmap文件在方便的地方,并告诉GS通过使用-I开关来查看该目录,该开关添加目录到搜索列表的头部。它的重要性在于它的头部,因为你只能有一个cidfmap文件,而GS使用它找到的第一个。



所以,就到了字体文件本身。您可以使用真正的CIDFont,也可以使用TrueType字体替代CIDFont。如果您使用真正的CIDFont,那么您必须使用上面的选项1(GenericResourceDir),并将该文件放在GenericResourceDir位置下名为Resource / CIDFonts的目录中,否则使用选项2并将CIDFont放在名为CIDFonts的目录下,直接放在-I所指向的位置。



如果使用TrueType字体作为替代,则可以使用在cidfmap中字体条目中的/ Path键指向TrueType字体。

将未知出处的TrueType字体转换为特定类型的CIDFont意味着您必须在cidfmap条目中提供大量信息,这在文件本身中有记录。注意事项:
$ b $ 1)/路径必须指向字体文件,它必须存在,并有权限读取它。



2)您应该为TrueType集合提供一个/ SubfontID。如果您想使用除第一个子文件之外的任何内容,那么您必须提供一个SubfontID。
$ b $ cidfmap中的条目由PostScript解释器等都必须符合PostScript语法。特别是字体名称是一个PostScript名称对象,所以必须使用'/'来引入。



最后;许多Linux发行版都没有提供Ghostscript的完整源代码,您可能需要在使用上述任何建议之前选择它。你可以从这里得到释放:



http:// www。 ghostscript.com/


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:

  1. Because the not embedded font is outside the TrimBox region, there is a GS parameter that permit to skip not embedded font?
  2. If point 1 is not possible how is possible to substitute the missing font?
  3. My Installation of GS 9.02 on OS X don't install cidfmap file nor fonts folders.
  4. What I need to install and where in order to use substitute fonts?
  5. 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:

http://www.ghostscript.com/

这篇关于使用不使用GhostScript嵌入的字体栅格化PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆