我想使用 Ghostscript 9.15 将任意 PDF 文件转换为 PDF/A。
Ghostscript 是否能够创建符合 PDF/A-3b 的 PDF?没有代表 PDF/A 一致性级别的参数,所以我认为不可能。还是我忽略了什么?
我正在关注一篇博客文章,其中使用 Windows 批处理文件将 PDF 转换为 PDF/A(请参阅http://www.mcbsys.com/techblog/2013/04/batch-convert-pdf-to-pdfa/) . 批处理中的
gs
调用是:"%gs_path%\gswin64c" ^ -dPDFA ^ -dNOOUTERSAVE ^ -sProcessColorModel=DeviceRGB ^ -sDEVICE=pdfwrite ^ -o "GS_%file1%" ^ -dPDFACompatibilityPolicy=1 ^ "%currentdir%\PDFA_def.ps" ^ %inputfilelist%
这PDFA_def.ps
是官方版本的调整版:
%!
% This prefix file for creating a PDF/A document is derived from
% the sample included with Ghostscript 9.07, released under the
% GNU Affero General Public License.
% Modified 4/15/2013 by MCB Systems.
% Feel free to modify entries marked with "Customize".
% This assumes an ICC profile to reside in the file (AdobeRGB1998.icc),
% unless the user modifies the corresponding line below.
% The color space described by the ICC profile must correspond to the
% ProcessColorModel specified when using this prefix file (GRAY with
% DeviceGray, RGB with DeviceRGB, and CMYK with DeviceCMYK).
% Define entries in the document Info dictionary :
/ICCProfile (... PATH TO ... AdobeRGB1998.icc) % Customize.
def
[ /Title (Title) % Customize.
/DOCINFO pdfmark
% Define an ICC profile :
[/_objdef {icc_PDFA} /type /stream /OBJ pdfmark
[{icc_PDFA} <</N systemdict /ProcessColorModel get /DeviceGray eq {1} {systemdict /ProcessColorModel get /DeviceRGB eq {3} {4} ifelse} ifelse >> /PUT pdfmark
[{icc_PDFA} ICCProfile (r) file /PUT pdfmark
% Define the output intent dictionary :
[/_objdef {OutputIntent_PDFA} /type /dict /OBJ pdfmark
[{OutputIntent_PDFA} <<
/Type /OutputIntent % Must be so (the standard requires).
/S /GTS_PDFA1 % Must be so (the standard requires).
/DestOutputProfile {icc_PDFA} % Must be so (see above).
/OutputConditionIdentifier (AdobeRGB1998) % Customize
>> /PUT pdfmark
[{Catalog} <</OutputIntents [ {OutputIntent_PDFA} ]>> /PUT pdfmark
因此,我使用AdobeRGB1998.icc,它显然可用于具有 RGB 颜色空间的 PDF 文件。根据-sProcessColorModel
值 (DEVICERGB) 打印出正确的值。
转换适用于所有文件。但是当我根据 PDF/A-1b 验证创建的 PDF 文件时,我会得到不同的结果,具体取决于输入文件是否具有 RGB 颜色空间(例如 CMYK)。因此,当我有一个使用 CMYK 颜色空间的输入 PDF 文件时,该文件会被脚本转换,但验证器会这样说:
input.pdf", 1, 38, 0x03418614, "A device-specific color space (DeviceCMYK) without an appropriate output intent is used.", 1
"output.pdf", 20, 0, 0x83410612, "The document does not conform to the requested standard.", 1
我的问题:有没有办法为任意文件完成转换(即独立于输入文件中使用的颜色空间)?
更新
@KenS 感谢您的回答。我已经更新了我最初的帖子,以澄清我想要实现的目标。
为了更明确,我将使用一个示例。有两个文件:(input1.pdf
似乎使用RGB)和input2.pdf
(似乎使用CMYK)。我想将它们都转换为 PDF/A-1。感谢您的提示,我已经放弃了上述批处理脚本,而是直接在命令行中测试了该命令。阅读Ps2pdf.htm#PDFA后,我调整了(官方)PDFA_def.ps以便使用 Adob eRGB1998.icc。然后我对两个输入文件调用了以下命令(将 output1.pdf 替换为output2.pdf 和 input1.pdf 由input2.pdf替换为第二个文件):
gswin64c.exe -dPDFA=1 -dBATCH -dNOPAUSE -dNOOUTERSAVE \
-sColorConversionStrategy=/RGB \
-sOutputICCProfile=AdobeRGB1998.icc -sDEVICE=pdfwrite \
-sOutputFile=output1.pdf -dPDFACompatibilityPolicy=1 \
"PATH/TO/OFFICIAL/PDFA_def.ps" input1.pdf
转换完成,没有任何错误。output1.pdf 似乎有效,但 output2.pdf 仍然无效(使用 3heights Validator 测试):
"output2.pdf", 1, 40, 0x03418614, "A device-specific color space (DeviceCMYK) without an appropriate output intent is used.", 1
"output2.pdf", 20, 0, 0x83410612, "The document does not conform to the requested standard.", 1
因此,当我正确理解您的答案时,上述命令应生成一个使用 RGB 颜色空间的 pdf 文件 - 与输入文件的颜色空间无关。如果输入文件使用 CMYK,则必须使用上述命令将颜色转换为 RGB。
当我正确解释第一条错误消息时,output2.pdf 中使用的颜色空间仍然是 CMYK(尽管命令参数如 ColorConversionStrategy=/RGB)。由于我使用的是AdobeRGB1998.icc,所以出现验证错误。
我在上面的命令中缺少什么?
回到我最初的问题(更进一步):我不想总是转换为 RGB(或 CMYK),而是想以某种方式检测输入文件中使用了哪种颜色空间,然后动态切换到 RGB 或 CMYK icc 文件. 有可能实现吗?