首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ghostscritpt转换文件在adobe读取器中不可查看

Ghostscritpt转换文件在adobe读取器中不可查看
EN

Stack Overflow用户
提问于 2018-04-06 06:15:49
回答 1查看 768关注 0票数 2

我正在尝试执行pdf通过鬼脚本与-sDEVICE=pdfwrite进行pdf对话。对话是成功的,但第一页是空白的(rest页面很好);此外,adobe阅读器会给出一个错误:“处理页面时出错。操作数类型错误。”

命令:

cmd C:\app\others\GhostScript\9_21\bin\gswin64.exe -dPDFA=2 -dBATCH -dNOPAUSE -dNOPLATFONTS -dPDFSETTINGS=/打印机-sProcessColorModel=DeviceRGB -sDEVICE=pdfwrite -dCompatibilityLevel=1.7 -dOptimize=true -dPDFACompatibilityPolicy=1 -dAutoRotatePages=/None -sOutputFile="1107.pdf“test1.pdf

注意: pdfa文件可以在pdf-xchange查看器,chrome浏览器中读取(第一页)。问题只在土坯阅读器上。

输入pdf:test1.pdf

输出pdfa:1107.pdf

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-06 07:29:58

您正在使用的命令行有许多问题,我将在最后讨论这些问题。

首先要指出的是,您应该始终使用当前代码。9.21已经过时,目前的版本是9.23。当我通过当前版本运行该文件时,使用提供的命令行,我在stderr上得到了许多警告(或者,由于您使用的是窗口可执行文件,所以在窗口中):

代码语言:javascript
复制
GPL Ghostscript 9.23 (2018-03-21)
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 12.
Page 1
GPL Ghostscript 9.23: Setting Overprint Mode to 1
 not permitted in PDF/A-2, overprint mode not set

Attempting to write a DeviceN space with an inappropriate alternate,
have you set ColorConversionStrategy ?
Attempting to write a DeviceN space with an inappropriate alternate,
have you set ColorConversionStrategy ?
Attempting to write a DeviceN space with an inappropriate alternate,
have you set ColorConversionStrategy ?
Attempting to write a DeviceN space with an inappropriate alternate,
have you set ColorConversionStrategy ?
Attempting to write a DeviceN space with an inappropriate alternate,
have you set ColorConversionStrategy ?
Attempting to write a DeviceN space with an inappropriate alternate,
have you set ColorConversionStrategy ?
Attempting to write a DeviceN space with an inappropriate alternate,
have you set ColorConversionStrategy ?
Attempting to write a DeviceN space with an inappropriate alternate,
have you set ColorConversionStrategy ?
Attempting to write a DeviceN space with an inappropriate alternate,
have you set ColorConversionStrategy ?
Attempting to write a DeviceN space with an inappropriate alternate,
have you set ColorConversionStrategy ?
Attempting to write a DeviceN space with an inappropriate alternate,
have you set ColorConversionStrategy ?
Attempting to write a DeviceN space with an inappropriate alternate,
have you set ColorConversionStrategy ?
>>showpage, press <return> to continue<<

因此,这很大程度上告诉了您什么是错误的,您还没有设置ColorConversionStrategy。所有打开文件而没有抱怨的软件都是错误的。如果您通过Ghostscript将生成的PDF文件运行回显示器,它会显示如下:

代码语言:javascript
复制
GPL Ghostscript GIT PRERELEASE 9.24 (2018-03-21)
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 1.
Page 1
   **** Error: Considering object with an invalid number -1 as null.
               Output may be incorrect.
   **** Error: Considering object with an invalid number -1 as null.
               Output may be incorrect.
   **** Error reading a content stream. The page may be incomplete.
               Output may be incorrect.
   **** Error: File did not complete the page properly and may be damaged.
               Output may be incorrect.
>>showpage, press <return> to continue<<

通过设置-dPDFSTOPONERROR和-dPDFDEBUG,可以得到更多的刺激:

代码语言:javascript
复制
%Resolving: [-1 0]
   **** Error: Considering object with an invalid number -1 as null.
               Output may be incorrect.
%Pattern: << /PaintProc {<< >> .pdfpaintproc} /PatternType 2 /.pattern_uses_tran
sparency false /Matrix [0.000766095 -0.000451741 -0.000306278 -0.000529551 116.3
78 788.13] /Shading {-1 0 resolveR} >>
%Resolving: [-1 0]
   **** Error: Considering object with an invalid number -1 as null.
               Output may be incorrect.
Error: /typecheck in --makepattern--
Operand stack:
   --dict:11/19(L)--   --dict:5/13(L)--   --dict:5/13(L)--   --nostringval--   f
alse   --nostringval--   0.0   --nostringval--   --nostringval--   --dict:5/6(L)
--   --nostringval--   --nostringval--   --nostringval--   DataSource
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval-
-   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   fa
lse   1   %stopped_push   2015   1   3   %oparray_pop   2014   1   3   %oparray_
pop   1998   1   3   %oparray_pop   --nostringval--   --nostringval--   2   1
1   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--
  --nostringval--   --nostringval--   %array_continue   --nostringval--   --nost
ringval--   %loop_continue   --nostringval--   --nostringval--   1958   4   11
 %oparray_pop   --nostringval--   --nostringval--   false   1   %stopped_push
--nostringval--
Dictionary stack:
   --dict:984/1684(ro)(G)--   --dict:1/20(G)--   --dict:83/200(L)--   --dict:83/
200(L)--   --dict:133/256(ro)(G)--   --dict:307/450(ro)(G)--   --dict:33/64(L)--
   --dict:6/9(L)--   --dict:7/20(L)--   --dict:1/1(ro)(G)--   --dict:1/1(ro)(G)-
-
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript GIT PRERELEASE 9.24: Unrecoverable error, exit code 1

Close this window with the close button on the title bar or the system menu.

因此,您可以看到有一个具有无效数字(-1)的对象和一个试图使用该对象的阴影字典。这完全是非法的。

现在,原因是您设置了pdfwrite选项。

首先要注意的是,Ghostscript的pdfwrite设备不会“转换”PDF文件。所发生的情况是,输入被解释,转换为图形原语,准备好呈现,然后发送到呈现像素。然而,pdfwrite设备没有呈现原语,而是将它们重新打包为PDF文件。在相关的文档。中描述了这方面的一些后果

为了创建PDF/A文件,输出文件必须遵循某些规则;它不可能同时包含( RGB和CMYK颜色),它只能包含一个或另一个。因此,您应该做的第一件事是将-sColorConversionStrategy设置为RGB、CMYK或UseDeviceIndependentColor之一。设置ProcessColorModel是不够的。如果您设置了ColorConversionStrategy,那么将自动为您设置ProcessColorModel。这是最初的问题,修复会产生有效的PDF文件(但不是有效的PDF/A文件)。

PDF/A文件还必须包含一个ICC配置文件,即OutputIntent,除非该文件完全由灰色或独立于设备的颜色组成。你的命令行不会这么做。

同样,文档描述了如何创建PDF/A文件。

从基础开始,您设置了-dPDFSETTINGS。在我看来,这是一个非常糟糕的主意,尤其是在试图创建PDF/A文件时。这样做将改变许多设置,除非您绝对确定希望将所有这些设置设置为默认设置,否则不应该使用它。

我不会碰-dCompatibilityLevel,pdfwrite设备根据它写到输出文件的内容,适当地设置它所需的一致性级别。除非要将需要更高级别的PDF文件(使用pdfmark)结构添加到PDF文件中,否则所有这些都是将文件限制为由更新版本的Acrobat打开。

我不会使用-dOptimize,如果没有其他原因,那就是它没有做任何事情!如果您阅读了文档,那么在Distiller下面的注释0说明可以设置和查询这一点,但是没有任何效果。

pdfwrite的等价物是-dFastWebView,但我仍然不会使用它,因为它最无用,最多只能加快第一页的加载速度,而且只有当PDF使用者使用它时才会使用它,而大多数用户都不使用它。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49686527

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档