首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Acrobat DC飞行前处理非PDF文件

Acrobat DC飞行前处理非PDF文件
EN

Stack Overflow用户
提问于 2016-10-20 15:53:19
回答 1查看 358关注 0票数 0

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

也许我在搜索时没有使用正确的短语,但我无法找到如何强制只处理PDF文件。我已经发现,在Acrobat中,您可以指定源文件https://www.evermap.com/ActionWizardX.asp,但在DC中没有找到相应的源文件。

是否有一种强制操作仅处理PDF文件的方法?

编辑:

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

代码语言:javascript
复制
/* 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数据导出到文件中,但这似乎就足够了。

代码语言:javascript
复制
/* 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:

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

编辑4

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

最终脚本:

代码语言:javascript
复制
/* 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)
{
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-10-23 01:18:09

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40159111

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档