ghostscript转换为pdf-a - icc文件是否正确?

时间:2016-11-17 15:22:44

标签: pdf ghostscript

我在Windows系统上使用ghostscript 9.19。 当我从批处理文件运行ghostscript时,它会创建pdf。 当ghostscript从一个程序安排时,它会创建一个没有内容的pdf - 只有一个空白页面。 两种情况下的命令行都是相同的(一条长线,由于格式化而在下面分开):

gswin32c.exe  -sstdout=d:\my_data\gs_stdout.log  
        -dPDFA=1 -dBATCH -dNOPAUSE -dNOOUTERSAVE 
        -sColorConversionStrategy=/RGB 
        -sOutputICCProfile=d:\my_ps_files\AdobeRGB1998.icc 
        -sDEVICE=pdfwrite 
        -sOutputFile=d:\my_data\my_hopeful_pdfa_pdfa.pdf 
        -dPDFACompatibilityPolicy=1 "d:\my_ps_files/PDFA_def.ps" "d:\my_data\my_hopeful_pdfa_pdfa.ps" 
        > d:\my_data\my_hopeful_pdfa_gs_out.log 
永远不会创建

my_hopefule_pdfa_gs_out.log 。但是 gs_stdout.log 确实已经创建。

是否创建了pdf似乎与ghost。脚运行的目录中是否存在* .icc文件有关。

我在stdout.log文件中获得了不同的输出。

当它工作时,我得到:

GPL Ghostscript 9.19 (2016-03-23)
Copyright (C) 2016 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /undefinedfilename in (>)
Operand stack:
   false
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push
Dictionary stack:
   --dict:1201/1684(ro)(G)--   --dict:0/20(G)--   --dict:80/200(L)--
Current allocation mode is local
Last OS error: Invalid argument

失败时的错误日志是:

GPL Ghostscript 9.19 (2016-03-23)
Copyright (C) 2016 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /undefinedfilename in --file--
Operand stack:
   --nostringval--   --nostringval--   (AdobeRGB1998.icc)   (r)
Execution stack:
%interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1967   1   3   %oparray_pop   1966   1   3   %oparray_pop   1950   1   3   %oparray_pop   1836   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--       --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:1201/1684(ro)(G)--   --dict:0/20(G)--   --dict:79/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
Current file position is 818

有人可以帮我解释这个输出。两种情况下的AdobeRGB1988.icc都位于命令行中指定的 d:\ my_ps_files \ Adob​​eRGB1998.icc 中。

1 个答案:

答案 0 :(得分:2)

正斜杠是无关紧要的,Ghostscript可以处理任何一种类型,或者两者都在同一条路径中处理(虽然我同意,至少坚持一个或另一个是明智的。)

实际问题是它无法找到文件' Adob​​eRGB1998.icc' (在PostScript中,undefinedfilename表示解释器无法找到文件)并且没有看到PDFA_def.ps文件的内容,因此无法确切说明原因(因为文件是在PDFA_def.ps中打开的)

然而,一个合理的猜测是,在一种情况下,您正在从文件夹d:\ my_ps_files执行Ghostscript,因此ICC配置文件文件位于当前目录中,而在另一种情况下,您正在执行Ghostscript来自'其他一些'目录,因此该文件不在当前目录中。很明显,您修改了文件名,因为它不是默认名称,但看起来您没有指定完整的路径。

命令行中指定的''是指一个完全不同的调用,在这种情况下,您使用AdobeRGB1998.icc作为OutputICCProfile,但是,PDFA_def.ps需要使用它来设置OutputIntent字典中的DestOutptuProfile,这是一个完全不同的东西,并且不是在命令行中指定。这是因为无法在命令行上创建字典对象,因此必须在PostScript中完成,并且由于字典创建必须在PostScript中完成,因此创建其内容也是如此,其中一个是DestOutputProfile,因为从文件中读取,你需要在PostScript中指定它。

您应该将完整路径规范放在PDFA_def.ps中的ICC配置文件中,而不是将其隐式保留为当前工作目录。

请注意,DestOutputProfile和OutputICCProfile是不同的东西,需要为高级输出指定一个OutputICCProfile,这是一个用于渲染的控件,它在这里没有任何影响我和#39;放弃它。

您在批处理文件中出现错误的原因是'>'是一个shell命令,所以如果你把它放在批处理文件中它不会工作,它将作为命令行参数传递给Ghostscript。幸运的是,这在处理完成后会发生,所以它没有任何不良影响。它不会包含任何内容,因为您已将stdout重定向到文件。

不要设置-dNOOUTERSAVE,除非你有充分的理由,而不仅仅是民间传说(有充分的理由设置它,但你似乎并没有以这种方式使用它)。除非某些特定条件适用,否则这只会导致处理速度变慢(出于与垃圾收集相关的复杂原因)。

相关问题