繁体   English   中英

将 PDF 转换为 PDF/A 以使用 ghostscript

[英]Convert PDF to PDF/A to use ghostscript

我尝试使用下一个参数:

          '-dPDFA=2 ' +
          '-dBATCH ' +
          '-DNOSAFER ' +
          '-dNOPAUSE ' +
          '-sColorConversionStrategy=UseDeviceIndependentColor ' +
          '-sDEVICE=pdfwrite ' +
          '-dPDFACompatibilityPolicy=1 ' +
          '-o ./temp.pdf' +
          './PDFA_def.ps' +
          './out/temp.pdf'

我的 PDFA_def.ps 看起来像这样:

%!
% This is a sample prefix file for creating a PDF/A document.
% Users should modify entries marked with "Customize".
% This assumes an ICC profile resides in the file (srgb.icc),
% in the current directory unless the user modifies the corresponding line below.

% Define entries in the document Info dictionary :


% Define an ICC profile :
/ICCProfile (/Users/user/nestjs/ISOcoated_v2_300_eci.icc) % Customise
def

[/_objdef {icc_PDFA} /type /stream /OBJ pdfmark

%% This code attempts to set the /N (number of components) key for the ICC colour space.
%% To do this it checks the ColorConversionStrategy or the device ProcessColorModel if
%% ColorConversionStrategy is not set.
%% This is not 100% reliable. A better solution is for the user to edit this and replace
%% the code between the ---8<--- lines with a simple declaration like:
%%   /N 3
%% where the value of N is the number of components from the profile defined in /ICCProfile above.
%%
[{icc_PDFA}
<<
>> /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 (ISO Coated v2 300% (ECI)) % Customize
>> /PUT pdfmark
[{Catalog} <</OutputIntents [ {OutputIntent_PDFA} ]>> /PUT pdfmark

我在寻找解决方案时下载的 ISOcoat_v2_300_eci.icc。 我尝试使用 gs/lib/iccprofiles/ 中的默认 iccs 我尝试使用 -sColorConversionStrategy RGB、CMYK、Gray 而不是 UseDeviceIndependentColor 它没有帮助。 对话成功结束,Ghostscript 不会抛出任何错误。 但是当我在 veraPDF 中验证结果文件时,我得到以下报告(html 文件)。

你对我有什么想法吗?

更新

源文件

结果文件

一个直接的问题是您已将 Ghostscript 设置为生成 PDF/A-2 文件,并且您正在测试与 PDF/A-1 的一致性,这是一种较早的、更具限制性的标准。 您需要设置 PDFA=1 或测试 PDF/A-2 的一致性

如果使用 DeviceIndependentColor,则不需要指定 OutputIntent。 如果使用 RGB、CMYK 或灰色,则必须使用具有适当数量组件的 OutptuIntent。 我怀疑您在此过程中的某个地方没有做到这一点。

您没有提供输入文件或 output 文件,因此无法评论 HTML 文件中的许多错误报告,并且无法跟踪 html 文件中的链接。 我建议您提供源文件和 output 文件,以及这些特定文件的一致性报告。

[编辑]

使用上面的原始文件和 srgb.icc 配置文件(您不能使用 Ghostscript 配置文件,因为它们是版本 4 配置文件并且与 PDF/A-1 不兼容)以及 -sColorConversionStrategy=RGB 我制作了这个PFD/A-1b 文件. 使用当前版本的 VeraPDF,使用 PDF/A-1b 一致性测试进行无投诉地验证。

[另一个编辑]

使用当前代码和这个命令行:

gs -dNOSAFER -sDEVICE=pdfwrite -dPDFA=2 -sColorConversionStrategy=RGB -dPDFACompatibilityPolicy=1 -sOutputFile=pdfa2.pdf pdfa_def.ps "vertrag.pdf"

其中 vertrag.pdf 是原始输入文件,pdfa_def.ps 包含:

%!
% This is a sample prefix file for creating a PDF/A document.
% Users should modify entries marked with "Customize".
% This assumes an ICC profile resides in the file (srgb.icc),
% in the current directory unless the user modifies the corresponding line below.

% Define entries in the document Info dictionary :
[ /Title (Title)       % Customise
  /DOCINFO pdfmark

% Define an ICC profile :
/ICCProfile (/temp/srgb.icc) % Customise
def

[/_objdef {icc_PDFA} /type /stream /OBJ pdfmark

%% This code attempts to set the /N (number of components) key for the ICC colour space.
%% To do this it checks the ColorConversionStrategy or the device ProcessColorModel if
%% ColorConversionStrategy is not set.
%% This is not 100% reliable. A better solution is for the user to edit this and replace
%% the code between the ---8<--- lines with a simple declaration like:
%%   /N 3
%% where the value of N is the number of components from the profile defined in /ICCProfile above.
%%
[{icc_PDFA}
<<
%% ----------8<--------------8<-------------8<--------------8<----------
  systemdict /ColorConversionStrategy known {
    systemdict /ColorConversionStrategy get cvn dup /Gray eq {
      pop /N 1 false
    }{
      dup /RGB eq {
        pop /N 3 false
      }{
        /CMYK eq {
          /N 4 false
        }{
          (ColorConversionStrategy not a device space, falling back to ProcessColorModel, output may not be valid PDF/A.)=
          true
        } ifelse
      } ifelse
    } ifelse
  } {
    (ColorConversionStrategy not set, falling back to ProcessColorModel, output may not be valid PDF/A.)=
    true
  } ifelse

  {
    currentpagedevice /ProcessColorModel get
    dup /DeviceGray eq {
      pop /N 1
    }{
      dup /DeviceRGB eq {
        pop /N 3
      }{
        dup /DeviceCMYK eq {
          pop /N 4
        } {
          (ProcessColorModel not a device space.)=
          /ProcessColorModel cvx /rangecheck signalerror
        } ifelse
      } ifelse
    } ifelse
  } if
%% ----------8<--------------8<-------------8<--------------8<----------

>> /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 (sRGB) % Customize
>> /PUT pdfmark
[{Catalog} <</OutputIntents [ {OutputIntent_PDFA} ]>> /PUT pdfmark

(这是修改为使用 srgb ICC 配置文件的 Ghostscript 9.50 提供的示例)

我得到这个文件。 执行 VeraPDF(版本 1.14.8 Greenfield 解析器)的 PDF/A-2b 配置文件会给出绿色文本“PDF 符合验证配置文件要求”

我注意到你已经在你的 pdfa_def.ps 版本中剪掉了剪刀线,但是你没有按照说明添加像 /N 3 这样的行。 该值必须是正确的,它必须是 ICC 配置文件中的组件数,这就是您必须自己添加它的原因。 或者,当然,只需将尝试为您执行此操作的行留在原处。 如果您删除它们,则由您决定用正确的值替换它们。

请注意,Ghostscript 会发出几个警告,因为您的原始文件包含设置为 1 的叠印模式,这在 PDF/A-2 中是不允许的,有一个在 PDF/A-2 中不允许的非打印注释和一个字符串文档信息是 UTF16BE,这在 PDF/A-2(或 A-1)中也是不允许的。 由于您选择了 PDFACompatibilityPolicy,这些都将被删除,这可能会导致生成的 PDF 文件无法正确呈现。

作为一个额外的实验,我使用了这个命令行:

gs -dNOSAFER -sDEVICE=pdfwrite -dPDFA=2 -sColorConversionStrategy=UseDeviceIndependentColor -dPDFACompatibilityPolicy=1 -sOutputFile=pdfa2.pdf "vertrag.pdf"

因为它使用 DeviceIndependentColor,所以不需要执行 pdfa_def.ps(我们不需要 PDF 文件中的 OutputIntent),并且该文件使用相同版本的 VeraPDF 验证为兼容。

为了进行额外的完整性检查,我使用了 Acrobat Pro Preflight 工具来检查文件,这些文件也验证了它们是兼容的。

暂无
暂无

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

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