首页 > 解决方案 > centos7上的Ghostscript无法将pdf转换为jpg

问题描述

在 centos 7.5.1804 上通过 Ghostscript(9.07-29) 将 pdf 转换为 jpg 失败。网上很多说需要安装msttcorefonts,还是报错。

有谁知道如何解决这个问题?谢谢。

PDF文件: http: //pdf.dfcfw.com/pdf/H3_AP201709060860336298_1.pdf

错误日志:

GPL Ghostscript 9.07 (2013-02-14)
Copyright (C) 2012 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /undefined in --run--
Operand stack:
   905605   2   0   (\256\266\3637\306j\023{\342\000\017d\263\303\262\346\002\000\000\000\000)   --dict:1/1(L)--   Identity
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1884   1   3   %oparray_pop   1883   1   3   %oparray_pop   1867   1   3   %oparray_pop   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1167/1684(ro)(G)--   --dict:1/20(G)--   --dict:82/200(L)--   --dict:82/200(L)--   --dict:109/127(ro)(G)--   --dict:292/300(ro)(G)--   --dict:23/32(L)--
Current allocation mode is local

标签: pdfghostscript

解决方案


当前版本的 Ghostscript (9.25) 多次抱怨流的长度错误,但会打开文件并呈现它。我检查了我碰巧在这里的旧版本 9.07,它给出了你引用的错误。

所以我不得不猜测PDF文件有问题(即无效),旧版本的Ghostscript无法处理,但新版本已经更新处理。

您使用的 Ghostscript 版本很旧(日期戳在日志中),实际上它已有 5 年半的历史。您应该更新到当前版本。

我注意到 PDF 文件在生成 8 小时后显然被修改了,所以我猜是修改它的应用程序破坏了它。哦,PDF文件已被加密,这可能是造成损坏的原因。


推荐阅读