简体   繁体   English

Adobe DC-使用JavaScript另存为

[英]Adobe DC - Save As using JavaScript

This is my first attempt at using Javascript... 这是我第一次尝试使用Javascript ...

I am attempting to create a Save As button on a form that will: 我正在尝试在以下表单上创建“另存为”按钮:

  • Create a file name based on fields; 根据字段创建文件名;
  • Save to a specific folder (And if it doesn't exist then create folder); 保存到特定文件夹(如果不存在,则创建文件夹);
  • Bring up the "Save As" box for confirmation (as opposed to a silent save); 调出“另存为”框进行确认(而不是无声保存);
  • Bring up a warning IF Adobe is going to save over an existing pdf (aka has the exact same name); 如果Adobe将保存现有的pdf(又名完全相同),则发出警告。
  • Close Adobe after all of the above is executed. 执行上述所有操作后,关闭Adobe。

So far I have been fairly successful. 到目前为止,我已经相当成功。 I have been able to do a silent save, saving to a specific location and saving the file name based on fields. 我已经能够进行无提示保存,保存到特定位置并根据字段保存文件名。 I need help building the rest of the functionality into the code if possible. 如果可能,我需要帮助将其余功能构建到代码中。


The code I have so far is: 到目前为止,我的代码是:

Trusted Level Function saved in a Notepad.js file under the Adobe / Javascript folder 可信级别功能 保存在Adobe / Javascript文件夹下的Notepad.js文件中

mySaveAs = app.trustPropagatorFunction(function(doc,path) {
app.beginPriv();
doc.saveAs(path);
app.endPriv();
})


myTrustedSpecialTaskFunc = app.trustedFunction(function(doc,path) {
// Privileged and/or non-privileged code above
app.beginPriv();
mySaveAs(doc,path);
app.endPriv();
// Privileged and/or non-privileged code below
});

PDF Button Code under button that is executed on Mouse up click 在鼠标上单击时执行的 按钮 下的 PDF按钮 代码

// build file name
var myFileName = getField("Work_Pack").value + " - " + getField("Form_Name").value + " - " + getField("Todays_Date").value + ".pdf";
// add folder name
myFileName = "/c/temp/Saved Forms/" + myFileName
myTrustedSpecialTaskFunc(this, myFileName);

this.closeDoc() ;

Unfortunately, in Acrobat JavaScript, if you give the saveAs method a path that doesn't exist, the call will fail; 不幸的是,在Acrobat JavaScript中,如果为saveAs方法提供不存在的路径,则调用将失败;否则,调用将失败。 it can't create directories. 它无法创建目录。 You can't even set a default directory for it to save to, you need to give it the full path to the new PDF. 您甚至无法设置要保存到的默认目录,需要给它提供新PDF的完整路径。

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

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