问题描述
我面临与此.我正在使用GhostScript 9.14从Postscript文件创建有效的PDF/A.我正在调用以下命令:
I am faced with a quite similar issue as discussed in this thread. Using GhostScript 9.14 I am trying to create a valid PDF/A from a Postscript file. I am invoking following command:
"gswin64.exe" -dPDFA=1 -dBATCH -dNOPAUSE -dNOOUTERSAVE
-sColorConversionStrategy=/RGB -sOutputICCProfile=AdobeRGB1998.icc -sDEVICE=pdfwrite
-sOutputFile=output.pdf -dPDFACompatibilityPolicy=2 "PDFA_defRGB.ps" input.ps
这样做之后,我将通过Apache的PDFBox进行验证,并通过www.pdf-tools.com在线进行验证. PDF工具告诉我:
After doing so I validate via Apache's PDFBox and online via www.pdf-tools.com. PDF-tools tells me that:
Validating file "output.pdf" for conformance level pdfa-1b
A device-specific color space (DeviceCMYK) without an appropriate output intent is used.
The document does not conform to the requested standard.
The document contains device-specific color spaces.
如果我使用-sColorConversionStrategy=/CMYK
和适当的CMYK-.icc.file和PDFA_def,则验证也会失败.在这里,您去了:
If I use -sColorConversionStrategy=/CMYK
and an appropriate CMYK-.icc.file and PDFA_def the validations fails, too. Here you go:
Validating file "output.pdf" for conformance level pdfa-1b
The value of the key N is 3 but must be 4.
A device-specific color space (DeviceCMYK) without an appropriate output intent is used.
The document does not conform to the requested standard.
The document doesn't conform to the PDF reference (missing required entries, wrong value
types, etc.).
The document contains device-specific color spaces.
Java PDFBox验证令人惊讶地返回true(PDF/A有效).
Java PDFBox validation returns true surprisingly (PDF/A is valid).
如果我使用-sColorConversionStrategy=/UseDeviceIndependentColor
而不是/CMYK,则在线验证失败,结果如上. PDFBox再次返回有效文件.如果我将-sColorConversionStrategy=/UseDeviceIndependentColor
与RGB设置一起使用,如顶部所示,则在线验证失败与第一条错误消息相同:
If I use -sColorConversionStrategy=/UseDeviceIndependentColor
instead of /CMYK, online validation fails with the result as above. PDFBox returns a valid file again.If I use -sColorConversionStrategy=/UseDeviceIndependentColor
with RGB-settings as shown on top, online validation fails identical to the first error message:
Validating file "output.pdf" for conformance level pdfa-1b
A device-specific color space (DeviceCMYK) without an appropriate output intent is used.
The document does not conform to the requested standard.
The document contains device-specific color spaces.
PDFBox验证也会失败.
PDFBox validation fails as well.
使用-sProcessColorModel=DeviceCMYK
代替-sColorConversionStrategy
时,在线验证和PDFBox都检测到有效的PDF/A.
When using -sProcessColorModel=DeviceCMYK
instead of -sColorConversionStrategy
the online validation and PDFBox both detect a valid PDF/A.
output.pdf validated successfully.
Status Information
output.pdf (pdfa-1b)
那是什么问题?据我了解的GhostScript命令,-sColorConversionStrategy应该确保将输入PS的颜色空间转换为输出PDF的所需颜色空间-不知道输入文件具有什么颜色空间.显然这是不可能的,因为我还测试了具有明显色彩空间CMYK的ps文件,其结果与上面发布的结果相同.
So, what's the problem? As I understand the GhostScript command, -sColorConversionStrategy should ensure converting the color space of the input-PS into the desired color space of the output-PDF - without knowing what color space the input file has. Apparently that is not possible for I also tested a ps-file with obvious color space CMYK with same results as posted above.
我需要从Java代码中调用GhostScript,以获取未知的ps文件作为输入,将其转换为有效的PDF/A文件.那么,是否有可能使用GhostScript做到这一点,并且仅保证输入文件格式为Postscript?
I need to call GhostScript from Java code getting unknown ps-files as input converting them into valid PDF/A-files. So is there any possibility to use GhostScript doing that with the only guarantee that the input file format will be Postscript?
感谢您的帮助,
克里斯托弗
推荐答案
验证不是PDFBox的问题.正如我在GhostScript的错误网站上所讨论的(请参阅 http://bugs.ghostscript .com/show_bug.cgi?id = 695686#c10 )我在第一篇文章中描述的问题应该使用最新的Ghostscript代码(不是9.15版本,btw)解决.
The validation is not a problem of PDFBox. As I discussed on the bug-website from GhostScript (see http://bugs.ghostscript.com/show_bug.cgi?id=695686#c10) the problem I described in my first post should be solved with the newest code of Ghostscript (not the 9.15 version, btw).
我用一个肮脏的GS参数-dUseCIEColor解决了这个问题.所以我以这种方式调用GS:
I solved the issue with a dirty piece of GS-parameter called -dUseCIEColor instead. So I invoke GS this way:
"gswin64.exe" -dPDFA=1 -dBATCH -dNOPAUSE -dNOOUTERSAVE
-sColorConversionStrategy=/RGB -dUseCIEColor -sDEVICE=pdfwrite
-sOutputFile=output.pdf -dPDFACompatibilityPolicy=2 "PDFA_defRGB.ps" input.ps
尽管Ken Sharp不鼓励使用该参数,但此后我将继续使用它.我无法为我的公司编译GS的最新版本,仅允许使用现成的版本.使用-dUseCIEColor调用GS会产生有效的PDFA(Java PDFBox和www.pdf-tools.com).
Though Ken Sharp discourages the use of that parameter, I will use it henceforth. I am not able to compile the latest version of GS for my company, only ready-to-use versions are permitted. Calling GS with -dUseCIEColor produces valid PDFAs (Java PDFBox and www.pdf-tools.com).
这篇关于通过Ghostscript将PS文件转换为PDF/A,色彩空间问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!