我面临着与此thread中讨论的非常相似的问题。我正在尝试使用 GhostScript 9.14 从 Postscript 文件创建有效的 PDF/A。我正在调用以下命令:
"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-tools 告诉我:
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,验证也会失败。给你:
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 有效)。
如果我使用 -sColorConversionStrategy=/UseDeviceIndependentColor
而不是/CMYK,在线验证会失败,结果如上。 PDFBox 再次返回有效文件。
如果我将 -sColorConversionStrategy=/UseDeviceIndependentColor
与 RGB 设置一起使用(如顶部所示),则在线验证失败,与第一条错误消息相同:
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 验证也失败。
当使用 -sProcessColorModel=DeviceCMYK
而不是 -sColorConversionStrategy
时,在线验证和 PDFBox 都会检测到有效的 PDF/A。
output.pdf validated successfully.
Status Information
output.pdf (pdfa-1b)
那么,问题出在哪里呢?据我了解 GhostScript 命令,-sColorConversionStrategy 应确保将输入 PS 的颜色空间转换为输出 PDF 所需的颜色空间 - 而不知道输入文件具有什么颜色空间。显然这是不可能的,因为我还测试了具有明显色彩空间 CMYK 的 ps 文件,其结果与上面发布的结果相同。
我需要从 Java 代码调用 GhostScript,获取未知的 ps 文件作为输入,将它们转换为有效的 PDF/A 文件。那么是否有可能使用 GhostScript 来做到这一点,并且唯一保证输入文件格式为 Postscript?
感谢您的帮助,
克里斯托弗
最佳答案
验证不是PDFBox的问题。正如我在 GhostScript 的 bug 网站上讨论的那样(请参阅 http://bugs.ghostscript.com/show_bug.cgi?id=695686#c10 ),我在第一篇文章中描述的问题应该使用最新的 Ghostscript 代码(不是 9.15 版本,顺便说一句)来解决。
我用一个名为 -dUseCIEColor 的脏 GS 参数解决了这个问题。所以我这样调用 GS:
"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)。
关于validation - 通过Ghostscript将PS文件转换为PDF/A,色彩空间问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26970665/