【问题标题】:Acrobat DC preflight processes non-PDF filesAcrobat DC 预检处理非 PDF 文件
【发布时间】:2016-10-20 15:53:19
【问题描述】:

我想处理并验证文件夹中的 PDF 是有效的 PDF/A 文件。问题是我需要处理一个包含大量文件的文件夹,其中包括 word 和 excel 等文件,这些文件将预检转换为 PDF、处理,然后挂起等待用户输入以丢弃临时文件。有几百个文件,所以等待用户输入是不可行的。

也许我在搜索时没有使用正确的短语,但我不知道如何强制 Adob​​e Acrobat DC 仅处理 PDF 文件。我发现在 Acrobat X 中可以指定源文件 https://www.evermap.com/ActionWizardX.asp,但我在 DC 中没有找到对应的。

有没有办法强制一个动作只处理 PDF 文件?


编辑:

按照@Joel Geraci 的建议并找到this post,我创建了以下在动作中运行的脚本。此时,它似乎运行了配置文件,但我不知道它是否真的修改了文档,因为对this.closeDoc()的调用没有提示保存文档,并且生成的文档似乎不是保存为 PDF/A 文件。

/* Convert PDF/A-3a */
try
{
  if(this.path.split('.').pop() === 'pdf')
  {
    var oProfile = Preflight.getProfileByName("Convert to PDF/A-3a");

    if( oProfile != undefined )
    {
      var myPreflightResult = this.preflight( oProfile);
      console.println( "Preflight found " + myPreflightResult.numErrors + " Errors.");
      console.println( "Preflight found " + myPreflightResult.numWarnings + " Warnings.");
      console.println( "Preflight found " + myPreflightResult.numInfos + " Infos.");
      console.println( "Preflight fixed " + myPreflightResult.numFixed + " Errors.");
      console.println( "Preflight not fixed " + myPreflightResult.numNotFixed + " Errors.");
      this.closeDoc();
    }
  }
}
catch(theError)
{
  $error = theError;
  this.closeDoc( {bNoSave : true} );
}

编辑 2:

我最终决定使用saveAs 函数。我不确定如何将 XML 数据导出到文件,但这似乎就足够了。

/* Convert PDF/A-3a */
try
{
  if(this.path.split('.').pop() === 'pdf')
  {
    var oThermometer = app.thermometer;
    var oProfile = Preflight.getProfileByName("Convert to PDF/A-3a");

    if( oProfile != undefined )
    {
      var myPreflightResult = this.preflight( oProfile, false, oThermometer );
      console.println( "Preflight found " + myPreflightResult.numErrors + " Errors.");
      console.println( "Preflight found " + myPreflightResult.numWarnings + " Warnings.");
      console.println( "Preflight found " + myPreflightResult.numInfos + " Infos.");
      console.println( "Preflight fixed " + myPreflightResult.numFixed + " Errors.");
      console.println( "Preflight not fixed " + myPreflightResult.numNotFixed + " Errors.");
      if(myPreflightResult.numErrors > 0) {
        var cXMLData = myPreflightResult.report(oThermometer);
        console.println(cXMLData);
      }
      this.saveAs(path,"com.callas.preflight.pdfa");
    }
  }
}
catch(theError)
{
  $error = theError;
  this.closeDoc( {bNoSave : true} );
}

编辑 3:

所以问题是非 PDF 文件在我的 JavaScript 执行之前被转换和读取,这意味着 this.path.split('.').pop() === 'pdf' 实际上并没有过滤掉任何东西。我发现 Doc 类的 requiresFullSave 属性指定文档是否为临时文件。但是,我发现仍然询问我是否要保存临时文件,这没有帮助。

编辑 4

在临时文件上调用 Doc.closeDoc(true) 会导致 Acrobat 崩溃,而且似乎没有其他方法可以在不保存的情况下关闭文档。我发现没有明确的方法(我发现)在不提示用户保存的情况下关闭临时文档,并已诉诸删除所有非 PDF 文件。

最终脚本:

/* Convert PDF/A-3a */
try
{
  console.println(path + " is temp: " + requiresFullSave);
  if(!requiresFullSave)
  {
    var oThermometer = app.thermometer;
    var oProfile = Preflight.getProfileByName("Convert to PDF/A-3a");

    if( oProfile != undefined )
    {
      var myPreflightResult = this.preflight( oProfile, false, oThermometer );
      console.println( "Preflight found " + myPreflightResult.numErrors + " Errors.");
      console.println( "Preflight found " + myPreflightResult.numWarnings + " Warnings.");
      console.println( "Preflight found " + myPreflightResult.numInfos + " Infos.");
      console.println( "Preflight fixed " + myPreflightResult.numFixed + " Errors.");
      console.println( "Preflight not fixed " + myPreflightResult.numNotFixed + " Errors.");
      if(myPreflightResult.numErrors > 0) {
        var cXMLData = myPreflightResult.report(oThermometer);
        console.println(cXMLData);
      }
      this.saveAs(path,"com.callas.preflight.pdfa");
    }
  }
  else{
    // As noted in the documentation found [here][2]
    // Note:If the document is temporary or newly created, setting dirty to false has no effect. That is, the user is still asked to save changes before closing the document. See requiresFullSave.
    // this.dirty = false; 
    // this.closeDoc(true);
  }
}
catch(theError)
{
}

【问题讨论】:

    标签: pdf acrobat


    【解决方案1】:

    与其创建一个运行预检的动作,不如尝试创建一个运行一些 JavaScript 的动作。 JavaScript 将测试正在处理的文件的文件扩展名,如果是 PDF,则通过 JavaScript 执行预检,如果不是,则跳过它。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-09
    相关资源
    最近更新 更多