Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将PDF转换为PDF/A以使用ghostscript_Pdf_Ghostscript_Pdfa - Fatal编程技术网

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

将PDF转换为PDF/A以使用ghostscript,pdf,ghostscript,pdfa,Pdf,Ghostscript,Pdfa,我尝试使用以下参数: '-dPDFA=2 ' + '-dBATCH ' + '-DNOSAFER ' + '-dNOPAUSE ' + '-sColorConversionStrategy=UseDeviceIndependentColor ' + '-sDEVICE=pdfwrite ' + '-dPDFACompatibilityPolicy=1 ' +

我尝试使用以下参数:

          '-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

%!
%这是一个用于创建PDF/a文档的示例前缀文件。
%用户应修改标有“自定义”的条目。
%这假设ICC配置文件驻留在文件(srgb.ICC)中,
%在当前目录中,除非用户修改下面的相应行。
%在文档信息字典中定义条目:
%定义ICC配置文件:
/ICCProfile(/Users/user/nestjs/ISOcoated\u v2\u 300\u eci.icc)%Customize
def
[/_objdef{icc_PDFA}/type/stream/OBJ pdfmark
%%此代码尝试设置ICC颜色空间的/N(组件数量)键。
%%为此,如果需要,它会检查ColorConversionStrategy或设备进程ColorModel
%%未设置颜色转换策略。
%%这不是100%可靠。更好的解决方案是由用户编辑并替换
%%---8/PUT pdfmark之间的代码
[{icc_PDFA}ICCProfile(r)文件/PUT pdfmark
%定义输出意图字典:
[/\u objdef{outputinetent\u PDFA}/type/dict/OBJ pdfmark
[{OutputIntent\u PDFA}>/PUT pdfmark
[{Catalog}/PUT pdfmark
我查找解决方案时下载的ISOcoated_v2_300_eci.icc。 我尝试使用gs/lib/iccprofile中的默认ICC/ 我尝试使用-scoolorConversionStrategyRGB、CMYK、Gray而不是使用DeviceIndependentColor,这没有帮助。 对话成功结束,Ghostscript不会抛出任何错误 (html文件)

你对我有什么想法吗

更新


一个直接的问题是,您已经设置了Ghostscript来生成PDF/a-2文件,并且您正在测试是否符合PDF/a-1,这是一个更早、更严格的标准。您需要设置PDFA=1或测试PDF/a-2的一致性

如果您使用DeviceIndependentColor,则不需要指定OutputIntent。如果您使用RGB、CMYK或Gray,则必须使用具有适当数量组件的OutputIntent。我怀疑您在这方面做得不正确

您尚未提供输入文件或输出文件,因此无法对HTML文件中的许多错误报告发表评论,也无法遵循HTML文件中的链接。我建议您提供源文件和输出文件,以及这些特定文件的一致性报告

[编辑]

使用上面的原始文件和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
因为它使用DeviceIndependentColor,所以不需要执行pdfa_def.ps(我们不需要PDF文件中的输出内容),并且该文件还使用相同版本的VeraPDF验证为兼容


对于附加的健全性检查,我使用Acrobat Pro飞行前工具来检查文件是否兼容。

一个直接的问题是,您已经设置了Ghostscript以生成PDF/a-2文件,并且您正在测试是否符合PDF/a-1,这是一个较早的、更严格的标准。您需要设置PDFA=1或测试PDF/A-2的一致性

如果您使用DeviceIndependentColor,则不需要指定OutputIntent。如果您使用RGB、CMYK或Gray,则必须使用具有适当数量组件的OutputIntent。我怀疑您在这方面做得不正确

您尚未提供输入文件或输出文件,因此无法对HTML文件中的许多错误报告发表评论,也无法遵循HTML文件中的链接。我建议您提供源文件和输出文件,以及这些特定文件的一致性报告

[编辑]

使用上面的原始文件和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
因为它使用DeviceIndependentColor,所以不需要执行pdfa_def.ps(我们不需要PDF文件中的输出内容),并且该文件还使用相同版本的VeraPDF验证为兼容


为了进行额外的健全性检查,我使用Acrobat Pro飞行前工具检查了文件是否兼容。

我更新了我的问题。添加了源文件和结果文件。正如我前面所说,首先要做的是生成一个PDF/a-2文件,并验证与PDF/a-1的一致性,这根本行不通。如果想要一个PDF/a-1文件,那么你需要设置-dPDFA=1。另一方面,如果你想要一个PDF/a-2文件,那么你需要告诉VeraPDF测试与PDF/a-2的一致性。我使用PDFA-2配置进行了测试,得到了相同的结果。我稍后更新了问题,并添加了带有PDFA-2配置的vera报告。谢谢你的回答。我更新了我的问题。添加了源文件和结果文件正如我上面所说,第一件事是生成一个PDF/a-2文件,并验证与PDF/a-1的一致性,这根本不起作用。如果您想要一个PDF/a-1文件,则需要设置-dPDFA=1。另一方面,如果您想要一个PDF/a-2文件,则需要告诉VeraPDF测试与PDF/a-2的一致性。it我用PDFA-2配置进行了测试,得到了相同的结果。我后来更新了这个问题,并添加了一个带有PDFA-2配置的vera报告