简而言之,我正在处理一个有问题的 PDF,它:
evince
由于缺少字体信息,无法在文档查看器中完全呈现;- 但是 -
ghostscript
可以完全呈现相同的 PDF。
因此——不管用什么ghostscript
来填补空白(可能是备用字形,或访问字体的不同方法)——我希望能够用来ghostscript
生成(“蒸馏”)输出 PDF,其中几乎除了添加字体信息外,什么都不会改变,因此evince
可以以相同的方式呈现相同的文档ghostscript
。
因此,我的问题是——这有可能吗?如果是这样,命令行是什么来实现这样的目标?
非常感谢您的任何答案,
干杯!
细节:
我实际上使用的是较旧的 Ubuntu 10.04,我可能遇到了 - 不是错误 - 而是安装问题evince
(缺少poppler-data
软件包),如错误 #386008 “由于“未知字体标签而无法显示某些字体”中所述。 ..”:错误:“poppler”包:Ubuntu。
但是,这正是我想要处理的,所以我将使用该fontspec.pdf
帖子的附件(“ PDF 触发错误。 ”,// v.)来演示问题。
evince
首先,我打开这个 pdf 的第 3 页evince
;并evince
抱怨:
$ evince --page-label=3 fontspec.pdf
Error: Missing language pack for 'Adobe-Japan1' mapping
Error: Unknown font tag 'F5.1'
Error (7597): No font in show
Error: Unknown font tag 'F5.1'
Error (7630): No font in show
Error: Unknown font tag 'F5.1'
Error (7660): No font in show
Error: Unknown font tag 'F5.1'
...
渲染看起来像这样:
...很明显,缺少一些字体形状。
土坯acroread
只需说明 Adobe 的 Acrobat Reader for Linux 的行为方式;以下命令行:
$ ./Adobe/Reader9/bin/acroread /a "page=3" fontspec.pdf
... 不会向终端生成任何输出(有关/a
开关的更多信息,请参阅手册页 acroread)——并且程序显示字体绝对没有问题。
另外,虽然我想避免往返于 postscript - 但是,请注意它acroread
本身可用于将 PDF 转换为 postscript:
$ ./Adobe/Reader9/bin/acroread -v
9.5.1
$ ./Adobe/Reader9/bin/acroread -toPostScript \
-rotateAndCenter -choosePaperByPDFPageSize \
-start 3 -end 3 \
-level3 -transQuality 5 \
-optimizeForSpeed -saveVM \
fontspec.pdf ./
同样,上面的命令行不会向终端生成任何输出;-optimizeForSpeed -saveVM
在那里,因为显然他们处理字体;最后一个参数./
是输出目录(输出文件被自动调用fontspec.ps
)。
现在,evince
可以在输出中显示以前丢失的字体fontspec.ps
- 但再次抱怨:
$ evince fontspec.ps
GPL Ghostscript 9.02: Error: Font Renderer Plugin ( FreeType ) return code = -1
GPL Ghostscript 9.02: Error: Font Renderer Plugin ( FreeType ) return code = -1
...
...此外,所有文本似乎都在后记中被展平为曲线 - 所以现在无法再选择 .ps 文件中的文本evince
(请注意,.ps 文件无法在 中打开acroread
)。但是,可以再次将此 .ps 转换回 .pdf:
$ pstopdf fontspec.ps # note, `pstopdf` has no output filename option;
# it will automatically choose 'fontspec.pdf',
# and overwrite previous 'fontspec.pdf' in
# the same directory
...现在输出中的文本pstopdf
可以在 中选择evince
,所有字体都在那里,evince
不再抱怨。但是,正如我所指出的,我想完全避免往返于 postscript 文件。
display
(来自imagemagick
)
imagemagick
我们还可以使用s观察同一文档中的页面display
(请注意,使用 'display' 从命令行进行图像平移显然仍然不可用,因此我在-crop
下面使用来调整视口):
$ display -density 150 -crop 740x450+280+200 fontspec.pdf[2]
**** Warning: considering '0000000000 00000 n' as a free entry.
...
**** This file had errors that were repaired or ignored.
**** The file was produced by:
**** >>>> Mac OS X 10.5.4 Quartz PDFContext <<<<
**** Please notify the author of the software that produced this
**** file that it does not conform to Adobe's published PDF
**** specification.
...这会产生一些ghostscrip
ish 错误 - 结果如下:
...很明显,evince
无法渲染的缺失字体现在正确显示在此处,并带有imagemagick
s display
。
ghostscript
最后,我们可以使用 ghostscript 作为 x11 查看器本身——观察相同的页面、相同的文档:
$ gs -sDevice=x11 -g740x450 -r150x150 -dFirstPage=3 \
-c '<</PageOffset [-120 520]>> setpagedevice' \
-f fontspec.pdf
GPL Ghostscript 9.02 (2011-03-30)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
**** Warning: considering '0000000000 00000 n' as a free entry.
**** Warning: considering '0000000000 00000 n' as a free entry.
**** Warning: considering '0000000000 00000 n' as a free entry.
**** Warning: considering '0000000000 00000 n' as a free entry.
**** Warning: considering '0000000000 00000 n' as a free entry.
**** Warning: considering '0000000000 00000 n' as a free entry.
**** Warning: considering '0000000000 00000 n' as a free entry.
Processing pages 3 through 74.
Page 3
>>showpage, press <return> to continue<<
^C
...以及此输出的结果:
总之:(ghostscript
显然通过扩展,imagemagick
)似乎可以找到丢失的字体(或至少对其进行一些替换),并使用该字体呈现页面 - 即使evince
对于同一文档失败。
因此,我只想从 中导出 PDF 版本ghostscript
,该版本仅嵌入缺少的字体,没有其他处理;所以我试试这个:
$ gs -dBATCH -dNOPAUSE -dSAFER \
-dEmbedAllFonts -dSubsetFonts=true -dMaxSubsetPct=99 \
-dAutoFilterMonoImages=false \
-dAutoFilterGrayImages=false \
-dAutoFilterColorImages=false \
-dDownsampleColorImages=false \
-dDownsampleGrayImages=false \
-dDownsampleMonoImages=false \
-sDEVICE=pdfwrite \
-dFirstPage=3 -dLastPage=3 \
-sOutputFile=mypg3out.pdf -f fontspec.pdf
GPL Ghostscript 9.02 (2011-03-30)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
**** Warning: considering '0000000000 00000 n' as a free entry.
**** Warning: considering '0000000000 00000 n' as a free entry.
**** Warning: considering '0000000000 00000 n' as a free entry.
**** Warning: considering '0000000000 00000 n' as a free entry.
**** Warning: considering '0000000000 00000 n' as a free entry.
**** Warning: considering '0000000000 00000 n' as a free entry.
**** Warning: considering '0000000000 00000 n' as a free entry.
Processing pages 3 through 3.
Page 3
**** This file had errors that were repaired or ignored.
**** The file was produced by:
**** >>>> Mac OS X 10.5.4 Quartz PDFContext <<<<
**** Please notify the author of the software that produced this
**** file that it does not conform to Adobe's published PDF
**** specification.
...但它不起作用 - 输出文件遇到与前面提到 mypg3out.pdf
的完全相同的问题。evince
注意:虽然我想避免 postscript 往返,但gs
这里有一个从 pdf 到 ps 的带有字体嵌入的命令行的好例子:(#277826) pdf - 如何使 GhostScript PS2PDF 停止子集字体;但是 .pdf 到 .pdf 的相同命令行切换似乎对上述问题没有任何影响。