Ghostscript:使用嵌入字体而不是轮廓曲线将PDF转换为EPS [英] Ghostscript: convert PDF to EPS with embeded font rather than outlined curve

查看:409
本文介绍了Ghostscript:使用嵌入字体而不是轮廓曲线将PDF转换为EPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下命令将PDF转换为EPS:

I use the following command to convert a PDF to EPS:

gswin32 -dNOCACHE -dNOPAUSE -dBATCH -dSAFER -sDEVICE=epswrite -dLanguageLevel=2 -sOutputFile=test.eps -f test.pdf

然后我使用以下命令将EPS转换为另一个PDF(test2.pdf),以查看EPS数字.

I then use the following command to convert the EPS to another PDF (test2.pdf) to view the EPS figure.

gswin32 -dSAFER -dNOPLATFONTS -dNOPAUSE -dBATCH -dEPSCrop -sDEVICE=pdfwrite -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -sOutputFile=test2.pdf -f test.eps

我发现生成的test2.pdf中的文本已转换为轮廓曲线.也没有嵌入任何字体.

I found the text in the generated test2.pdf have been converted to outline curves. There is no font embedded anymore either.

是否可以将PDF转换为EPS而无需将文本转换为轮廓?我的意思是,对于带有嵌入式字体和文本的EPS.

Is it possible to convert PDF to EPS without convert text to outlines? I mean, to EPS with embedded font and text.

转换后(test.pdf-> test.eps-> test2.pdf),PDF图形(test2.pdf)的高度和宽度也比原始PDF(test.pdf)稍小:

Also after the conversion (test.pdf -> test.eps -> test2.pdf), the height and width of the PDF figure (test2.pdf) is a little bit smaller than the original PDF (test.pdf):

test.pdf:

test2.pdf:

test2.pdf:

转换后能否保持图形的宽度和高度?

Is it possible to keep the width and height of the figure after conversion?

这里是test.pdf: https://dl.dropboxusercontent.com/u/45318932/test.pdf

Here is the test.pdf: https://dl.dropboxusercontent.com/u/45318932/test.pdf

我尝试了KenS的建议:

I tried KenS's suggestion:

gswin32 -dNOPAUSE -dBATCH -dSAFER -sDEVICE=eps2write -dLanguageLevel=2 -sOutputFile=test.eps -f test.pdf
gswin32 -dSAFER -dNOPLATFONTS -dNOPAUSE -dBATCH -dEPSCrop -sDEVICE=pdfwrite -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -sOutputFile=test2.pdf -f test.eps

我可以看到转换后的test2.pdf具有非常奇怪的字体:

I can see the converted test2.pdf have very weird font:

与test.pdf中的原始字体不同:

that is different from the original font in test.pdf:

当我从test2.pdf复制文本时,我只会得到几个符号,例如:

When I copy the text from test2.pdf, I only get a couple of symbols like:

✕ ✖ ✗✘✙ ✚✛

这是test2.pdf: https://dl.dropboxusercontent.com/u/45318932/test2.pdf

Here is the test2.pdf: https://dl.dropboxusercontent.com/u/45318932/test2.pdf

我正在使用最新的Ghostscript 9.15.那是什么问题呢?

I was using the latest Ghostscript 9.15. So what is the problem?

推荐答案

我刚刚注意到您正在使用epswrite,但您不想这样做.该设备很糟糕,已被弃用(现在已卸下).请改用eps2write设备(您将需要相对较新的Ghostscript版本).

I just noticed you are using epswrite, you don't want to do that. That device is terrible and has been deprecated (and removed now). Use the eps2write device instead (you will need a relatively recent version of Ghostscript).

除了将其丢掉,epswrite您无能为力,它会使EPS文件变得糟透了.不管您将-dLanguageLevel设置为什么,它都不能创建2级文件

There's nothing you can do with epswrite except throw it away, it makes terrible EPS files. It also can't make level 2 files, no matter what you set -dLanguageLevel to

哦,不要使用-dNOCACHE,它可以防止处理字体并将所有内容分解为轮廓或位图.

oh, and don't use -dNOCACHE, that prevents fonts being processed and decomposes everything to outlines or bitmaps.

更新

您将子集字体设置为true.通过这样做,所使用的字符代码或多或少是随机的.文档中的第一个字形(例如,"Hello World"中的"H")获取代码1,第二个字形(例如"e")获取代码2,依此类推.

You set subset fonts to true. By doing so the character codes which are used are more or less random. The first glyph in the document (say for example the 'H' in 'Hello World') gets the code 1, the second one (eg 'e') gets the code 2 and so on.

如果您有ToUnicode CMap,则Acrobat和其他阅读器可以将这些字符代码转换为Unicode代码点,而无需这些阅读器退而求其次,最后一个是将其作为ASCII处理".因为不是 ASCII编码方式,所以您会觉得很乱. MS Windows的PostScript输出可以包含其他ToUnicode信息,但这不是我们试图在ps2write中模仿的东西.毕竟,大概您已经有了一个PDF文件....

If you have a ToUnicode CMap, then Acrobat and other readers can convert these character codes to Unicode code points, without that the readers have to fall back on heuristics, the final one being 'treat it as ASCII'. Because the encoding arrangement isn't ASCII, then you get gibberish. MS Windows' PostScript output can contain additional ToUnicode information, but that's not something we try to mimic in ps2write. After all, presumably you had a PDF file already....

每次进行转换时,您都冒着这种降级的风险,您应该真正尝试在工作流程中尽量减少这种情况.

Every time you do a conversion you run the risk of this kind of degradation, you should really try and minimise this in your workflow.

在这种情况下,问题甚至更严重,输入的PDF文件具有TrueType CID字体.基本语言级别2 PostScript无法处理CIDFonts(2015年引入的IIRC).由于eps2write仅发出基本级别2,因此无法将字体写为CIDFont.因此,它捕获字形轮廓并将其存储为3型字体.

The problem is even worse in this case, the input PDF file has a TrueType CID Font. Basic language level 2 PostScript can't handle CIDFonts (IIRC this was introduced in version 2015). Since eps2write only emits basic level 2 it cannot write the font as a CIDFont. So instead it captures the glyph outlines and stores them in a type 3 font.

但是,我们的EPS/PS输出不会尝试将ToUnicode信息嵌入到PostScript中(它是非标准的,很少有应用程序可以使用它,因此使文件变大而带来的好处很小).另外,CIDFonts使用多个(2个或更多)字节作为字符代码,因此无法将3类字体编码为ASCII.

However, our EPS/PS output doesn't attempt to embed ToUnicode information in the PostScript (its non-standard, very few applications can make use of it and it therefore makes the files larger for little benefit). In addition CIDFonts use multiple (2 or more) bytes for the character code, so there's no way to encode the type 3 fonts as ASCII.

从根本上讲,如果输入包含CIDFonts,则不能使用Ghostscript进入PDF-> PS-> PDF,并且仍然能够复制/粘贴/搜索文本.

Fundamentally you cannot use Ghostscript to go PDF->PS->PDF and still be able to copy/paste/search text, if the input contains CIDFonts.

顺便说一句,根本没有必要设置-dLanguageLevel. eps2write only 仅创建2级输出.

By the way, there's no point in setting -dLanguageLevel at all. eps2write only creates level 2 output.

这篇关于Ghostscript:使用嵌入字体而不是轮廓曲线将PDF转换为EPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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