简体   繁体   English

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

[英]ghostscript converting to pdf-a - icc file correct?

I'm using ghostscript 9.19 on a windows system. 我在Windows系统上使用ghostscript 9.19。 When I run ghostscript from a batch file, it creates the pdf. 当我从批处理文件运行ghostscript时,它将创建pdf。 When ghostscript is scheduled from a program, it creates a pdf without content - there's just one blank page. 当从程序计划了ghostscript时,它将创建一个没有内容的pdf-只有一个空白页。 The command line is the same in both cases (one Long line, split up below due to formating): 在这两种情况下,命令行都是相同的(一个长行,由于格式化而在下面分解):

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 never gets created. my_hopefule_pdfa_gs_out.log永远不会被创建。 But gs_stdout.log does get created. 但是gs_stdout.log确实已创建。

Whether a pdf gets created appears to be related to whether or not the *.icc file is present in the Directory where ghostscript runs. 是否创建pdf似乎与* .icc文件是否存在于运行ghostscript的目录中有关。

I get different output in the stdout.log file. 我在stdout.log文件中得到了不同的输出。

When it works I get: 当它起作用时,我得到:

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

The error log when it fails is: 失败时的错误日志为:

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

Can someone help me with interpreting this output. 有人可以帮我解释这个输出。 AdobeRGB1988.icc in both cases resides in d:\\my_ps_files\\AdobeRGB1998.icc as specified in the command line. 在两种情况下,AdobeRGB1988.icc都位于命令行中指定的d:\\ my_ps_files \\ Adob​​eRGB1998.icc中。

The forward slash is irrelevant, Ghostscript can handle either type, or both in the same path, as here (though I agree it would at least be sensible to stick to one or the other). 正斜杠无关紧要,Ghostscript可以像在这里一样在同一路径中处理任何一种或两种类型(尽管我同意至少坚持使用一种或另一种是明智的)。

The actual problem is that it can't find the file 'AdobeRGB1998.icc' (in PostScript undefinedfilename means the interpreter cannot find a file) and without seeing the contents of the PDFA_def.ps file its impossible to say why exactly (because the file is opened in PDFA_def.ps) 实际的问题是它无法找到文件“ Adob​​eRGB1998.icc”(在PostScript中,undefinedfilename意味着解释器无法找到文件),而且没有看到PDFA_def.ps文件的内容,也无法确切地说出原因(因为该文件)在PDFA_def.ps中打开)

However a plausible guess would be that in one case you are executing Ghostscript from the folder d:\\my_ps_files, so the ICC profile file is in the current directory, whereas in the other case you are executing Ghostscript from 'some other' directory, so the file is not in the current directory. 但是,有一种合理的猜测是,在一种情况下,您将从文件夹d:\\ my_ps_files执行Ghostscript,因此ICC配置文件在当前目录中,而在另一种情况下,您正在从“其他”目录中执行Ghostscript,因此该文件不在当前目录中。 Clearly you modified the filename in there as that's not the default name, but it looks like you did not specify a complete path. 显然,您在其中修改了文件名,因为它不是默认名称,但看起来您没有指定完整路径。

The 'as specified in the command line' refers to a completely different invocation, in this case you are using AdobeRGB1998.icc as the OutputICCProfile, however, PDFA_def.ps needs to use it to set the DestOutptuProfile in the OutputIntent dictionary, which is a different thing altogether and is not specified on the command line. “在命令行中指定”是指完全不同的调用,在这种情况下,您使用AdobeRGB1998.icc作为OutputICCProfile,但是PDFA_def.ps需要使用它来设置OutputIntent字典中的DestOutptuProfile,这是一个完全不同,并且在命令行上指定。 This is because there is no way to create a dictionary object on the command line, so it has to be done in PostScript, and since the dictionary creation has to be done in PostScript, so does the creation of its contents, and one of those is the DestOutputProfile, and since that's read from a file you need to specify that in PostScript too. 这是因为无法在命令行上创建字典对象,因此必须在PostScript中完成,并且由于必须在PostScript中完成字典的创建,因此也必须创建其内容,其中之一是DestOutputProfile,由于是从文件中读取的,因此您也需要在PostScript中指定它。

You should put a full path specification to the ICC profile in PDFA_def.ps instead of just leaving it as implicitly the current working directory. 您应该在PDFA_def.ps中为ICC配置文件添加完整的路径规范,而不是仅将其隐式保留为当前工作目录。

Note that the DestOutputProfile and the OutputICCProfile are different things, you do not need to specify a OutputICCProfile for high level output, that's a control for rendering, it has no effect here and I'd drop it. 需要注意的是DestOutputProfile和OutputICCProfile是不同的东西,你不需要指定高电平输出一个OutputICCProfile,这对渲染控制,在这里有没有影响,我会放弃它。

The reason you get an error at all in your batch file is because '>' is a shell command, so if you put it in a batch file it won't work, it will be passed to Ghostscript as a command line argument. 在批处理文件中完全出现错误的原因是“>”是一个shell命令,因此,如果将其放在批处理文件中将无法工作,它将作为命令行参数传递给Ghostscript。 Luckily for you this happens after the processing is complete, so it has no ill effects. 幸运的是,这是在处理完成后发生的,因此不会造成不良影响。 It wouldn't have contained anything anyway, since you've redirected stdout to a file. 无论如何,它不会包含任何内容,因为您已将stdout重定向到文件。

Don't set -dNOOUTERSAVE unless you have a good reason, not simply folklore (there is a good reason for setting it, but you don't appear to be using it in that way). 除非您有充分的理由,而不仅仅是民俗(除非有充分的理由进行设置,但您似乎并没有以这种方式使用它),否则请不要设置-dNOOUTERSAVE。 Unless certain specific conditions apply, this will do no more than potentially slow down processing (for complex reasons related to garbage collection). 除非适用某些特定条件,否则这样做只会导致处理速度减慢(由于与垃圾回收相关的复杂原因)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM