我想用Ghostscript 9.15将任意PDF文件转换为PDF/A。通过Ghostscript将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
invokation在批次:"%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以便使用AdobeRGB1998.icc。然后I(由input2.pdf取代output1.pdf通过output2.pdf和input1.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验证测试):
"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
所以,当我正确地理解你的答案,上面的命令应该产生它使用一个PDF文件RGB色彩空间 - 与输入文件的色彩空间无关。如果输入文件使用CMYK,则必须使用上述命令将颜色转换为RGB。
当我正确解释第一条错误消息时,output2.pdf中使用的颜色空间仍然是CMYK(尽管命令参数如ColorConversionStrategy =/RGB)。由于我使用了AdobeRGB1998.icc,因此出现验证错误。
我在上面的命令中缺少了什么?回到我原来的问题(这是更进一步):我不想总是转换为RGB(或CMYK),而是想以某种方式检测输入文件中使用哪种颜色空间,然后动态切换为RGB或CMYK icc文件。这有可能实现吗?
我也更新了我的答案,它不适合评论。 – KenS 2014-09-26 07:15:59
关于示例文件:有一个巴伐利亚州试用版,其中有许多pdf文件。您可以在这里下载所有文件:http://www.pdflib.com/fileadmin/pdflib/Bavaria/2009-04-03-Bavaria-pdfa.zip我测试的文件是“conforming \ Real world \ jmbl-2009-01 .PDF”。提前致谢! – codingAL 2014-09-26 07:31:47
这是一个40Mb的下载,只有一个文件,你可能会发现一个更小,可用的文件隔离? – KenS 2014-09-26 08:29:35