admin管理员组文章数量:1317909
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.
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.
Share Improve this question asked Feb 8, 2010 at 13:10 Christopher KlewesChristopher Klewes 11.4k18 gold badges76 silver badges102 bronze badges2 Answers
Reset to default 4But this doesn't save the pdf.
That's because there are security restrictions that prevent app.execMenuItem("Save");
from working. You're not allowed to call Save via JS.
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?
You can use Doc.path
to get the path of the current document including its filename (and Doc.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
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.
var mySaveAs = app.trustedFunction ( function(oDoc,cPath,cFlName)
{
app.beginPriv();
var flag=false;
cPath = cPath.replace(/([^\/])$/, "$1/");
if(cPath.indexOf("http://") !== -1 || cPath.indexOf("https://") !== -1)
{
cPath = cPath.replace('http://', "\\\\");
cPath = cPath.replace('https://', "\\\\");
while(cPath.indexOf("/") !== -1)
{
cPath = cPath.replace('/', "\\\\");
}
}
if(cPath.indexOf(":") !== -1)
{
cPath = cPath.replace(":","@");
}
try{
oDoc.saveAs(cPath + cFlName);
flag = true;
}catch(e){
app.alert("Error During Save");
}
app.endPriv();
return flag;
});
2) Code to save data at SharePoint.
var mySaveAs = app.trustedFunction ( function(oDoc,cPath,cFlName)
{
app.beginPriv();
var flag=false;
try{
app.execMenuItem("Save");
flag = true;
}catch(e){
app.alert("Error During Save");
}
app.endPriv();
return flag;
});
本文标签: apiAcrobat Javascript Save amp Exit ButtonStack Overflow
版权声明:本文标题:api - Acrobat Javascript Save & Exit Button - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742026464a2415634.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论