如何将PDF转换为图像而没有字体丢失?

问题描述 投票:0回答:1

我已经阅读了大量有关将字体(使用ghostscript)从PDF转换为图像时字体问题的stackoverflow问题。

因为您没有嵌入字体,所以ghostscript会尝试在您的系统中找到替代品并尽可能地渲染。

但我无法理解为什么我的Mac OS X预览渲染完美PDF和后记不能。

gs -sFONTPATH=/Library/Fonts -sDEVICE=pngalpha -o file-%03d.png -r144 my.pdf 

我甚至告诉gs字体在哪里。

这是输出。

$ pdffonts cv18.pdf 

Fontconfig warning: "/usr/local/etc/fonts/fonts.conf", line 86: unknown element "blank"
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
CenturyGothic,Bold                   TrueType          WinAnsi          no  no  no      13  0
CenturyGothic                        TrueType          WinAnsi          no  no  no      14  0
CourierNew                           TrueType          WinAnsi          no  no  no      15  0
Arial                                TrueType          WinAnsi          no  no  no      16  0
AYTOPC+Wingdings                     TrueType          WinAnsi          yes yes no      17  0
TimesNewRoman                        TrueType          WinAnsi          no  no  no      18  0
CenturyGothic,Italic                 TrueType          WinAnsi          no  no  no      24  0


$ gs -sDEVICE=pngalpha -o file-%03d.png -r300 cv18.pdf 

GPL Ghostscript 9.26 (2018-11-20)
Copyright (C) 2018 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 2.
Page 1
Querying operating system for font files...
Substituting font NewCenturySchlbk-Bold for CenturyGothic,Bold.
Loading C059-Bold font from /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/C059-Bold... 4357236 2918185 2219472 869812 4 done.
Substituting font NewCenturySchlbk-Roman for CenturyGothic.
Loading C059-Roman font from /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/C059-Roman... 4504148 3145674 2313416 951449 4 done.
Substituting font Courier for CourierNew.
Loading NimbusMonoPS-Regular font from /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/NimbusMonoPS-Regular... 4731860 3382093 2548760 1140366 4 done.
Can't find (or can't open) font file /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/ArialMT.
Can't find (or can't open) font file ArialMT.
Can't find (or can't open) font file /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/ArialMT.
Can't find (or can't open) font file ArialMT.
Didn't find this font on the system!
Substituting font Helvetica for ArialMT.
Loading NimbusSans-Regular font from /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/NimbusSans-Regular... 4939372 3576328 2589160 1183936 4 done.
Can't find (or can't open) font file /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/TimesNewRomanPSMT.
Can't find (or can't open) font file TimesNewRomanPSMT.
Can't find (or can't open) font file /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/TimesNewRomanPSMT.
Can't find (or can't open) font file TimesNewRomanPSMT.
Didn't find this font on the system!
Substituting font Times-Roman for TimesNewRomanPSMT.
Loading NimbusRoman-Regular font from /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/NimbusRoman-Regular... 5196116 3849418 3003064 1540393 4 done.
Page 2
Substituting font NewCenturySchlbk-Roman for CenturyGothic.
Substituting font NewCenturySchlbk-Bold for CenturyGothic,Bold.
Substituting font NewCenturySchlbk-Italic for CenturyGothic,Italic.
Loading C059-Italic font from /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/C059-Italic... 5504628 4138508 2467960 1088660 4 done.

问题是:为什么MacOSX Preview没有这个问题?从哪里获取字体,完美渲染?

ghostscript imagemagick-convert pdftoppm
1个回答
0
投票

我需要看到你的PDF文件能够发表评论,但你说“我甚至告诉gs字体在哪里”,我担心这似乎不正确。

Ghostscript后台频道说:

无法找到(或无法打开)字体文件/usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/ArialMT。

所以要么文件不存在,要么Ghostscript不能打开它,或者只是可能以某种方式损坏它。

fontconfig是你用来'告诉gs字体在哪里'的唯一东西吗?因为如果是这样,你并没有真正告诉Ghostscript。另请注意fontconfig警告,我不是font config的专家,但我怀疑你可能也想对它进行排序。

Ghostscript可能会,也可能不会使用fontconfig,具体取决于它是如何构建的,这显然是我不知道的。如果您实际上告诉Ghostscript有关字体(而不是fontconfig),那么它可能会更好。你需要编辑/创建一个fontmap.GS文件,并使用-I(Include)开关告诉Ghostscript在哪里找到它。

你可以在/ ghostscript / Resource / Init中找到一个示例fontmap.GS

为了帮助更多我需要知道字体文件所在的确切路径,您使用的方法告诉Ghostscript字体文件所在的位置,以及fontmap.GS的确切配置(或者其他任何意味着你正在使用)。如果字体文件以某种方式损坏,PDF文件和字体文件也会有所帮助。我也很好奇ArialMT和C059-Roman字体的格式。 PostScript或TrueType字体?

© www.soinside.com 2019 - 2024. All rights reserved.