Acrobat Javascript 保存并保存退出按钮
我有一个在 acrobat pro 中创建的可写 pdf 表单。现在,我添加了一个按钮,该按钮必须更改字段值、保存 pdf 并关闭它。
我决定按如下方式执行此操作:
var fieldX = this.getField("xxxxField");
fieldX.value = 1;
app.execMenuItem("Save");
this.closeDoc(true);
但这不会保存 pdf。
我不想有确认对话框。我在 API 中看到了 saveAs 函数,但是如何获取实际路径(包括)。当前编辑文档的文件名?或者您还有其他方法吗?
谢谢。
I have a writeable pdf form created in acrobat pro. Now, i added a button which has to change a fields value, save the pdf and close it.
I decided to do this as following:
var fieldX = this.getField("xxxxField");
fieldX.value = 1;
app.execMenuItem("Save");
this.closeDoc(true);
But this doesn't save the pdf.
I don't want to have a confirmation dialog. I saw the saveAs
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?
thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是因为存在安全限制,导致
app.execMenuItem("Save");
无法正常工作。不可以通过JS调用Save。您可以使用 Doc.path 获取当前文档的路径,包括其文件名(而 Doc.documentFilename 仅提供文件名)。
但是,
saveAs
也受到安全限制,并且只能在“特权”上下文(批处理或控制台)中调用。所以这也行不通。简而言之,安全限制将阻止您在未询问用户的情况下保存文档。如果你仔细想想,这也是合乎逻辑的。
请参阅:Acrobat JS API 参考
That's because there are security restrictions that prevent
app.execMenuItem("Save");
from working. You're not allowed to call Save via JS.You can use
Doc.path
to get the path of the current document including its filename (andDoc.documentFilename
gives you the filename only).However,
saveAs
is also subject to security restrictions, and it can only be called in a "privileged" context (batch or console). So this won't work either.In short, security restrictions will prevent you from saving documents without asking the user. If you think about it, it's only logical.
See: Acrobat JS API Reference
使用下面的链接或代码保存 PDF 数据的客户端代码。这是客户端可信函数,您需要将其放入
C:\Program Files\Adobe\...\JavaScript\Config.js。
如何使用 Acrobat JavaScript 保存 PDF
1) 在文件夹级别保存数据的代码。
2) 在SharePoint保存数据的代码。
Client side code to save PDF Data used below link or code. It's Client side trusted function which you need to put in
C:\Program Files\Adobe\...\JavaScript\Config.js.
How to Save a PDF with Acrobat JavaScript
1) Code to save data at folder level.
2) Code to save data at SharePoint.