我有一个在 acrobat pro 中创建的可写 pdf 表单。现在,我添加了一个按钮,该按钮必须更改字段值、保存 pdf 并关闭它。
我决定这样做:
var fieldX = this.getField("xxxxField");
fieldX.value = 1;
app.execMenuItem("Save");
this.closeDoc(true);
但这不会保存 pdf。
我不想出现确认对话框。我在 API 中看到了 saveAs 函数,但是如何获取实际路径(包括)。当前编辑文档的文件名?或者您还有其他方法吗?
谢谢。
最佳答案
But this doesn't save the pdf.
这是因为存在安全限制,导致 app.execMenuItem("Save");
无法工作。不允许通过JS调用Save。
function in the API but how to get the real-path incl. filename of the current editing document? Or do you have any other approaches?
您可以使用Doc.path
获取当前文档的路径,包括其文件名(Doc.documentFilename
仅提供文件名)。
但是,saveAs
也受到安全限制,并且只能在“特权”上下文(批处理或控制台)中调用。所以这也行不通。
简而言之,安全限制将阻止您在未询问用户的情况下保存文档。如果你仔细想想,这是合乎逻辑的。
关于javascript - Acrobat Javascript 保存和退出按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2221743/