Button 'SaveAs'

Avatar

Avatar

mipmater

Avatar

mipmater

mipmater

09-01-2009

I have been trying to setup a pdf to save to a predefined path with a click on a button.



I tried this code :



var aDocs = app.activeDocs;

var myDoc = aDocs[0];

myDoc.saveAs("C:\\" + Title.rawValue + ".pdf");



But i have this error :



myDoc has no properties

3:XFA:formulaire1[0]:#subform[0]:Bouton1[0]:click



Thanks in advance...

Replies

Avatar

Avatar

pguerett

Avatar

pguerett

pguerett

09-01-2009

You can save the current doc using the app.execMenuItem("SaveAs") this will bring up a dialog and allow the user to select the location for the saveed file. You cannot indicate where the file will go without certifying the document (Acrobat does not allow you to do unattended operations like that without the users knowledge).

Avatar

Avatar

mipmater

Avatar

mipmater

mipmater

09-01-2009

Thanks for your answer.



I have seen your previous posts about 'SaveAs', but my englich isn't very good and i don't understand everything.



I tried to do this, with the solution whow is explain in this post :

http://www.adobeforums.com/webx/.59b74b77



But i have this error



event.target.myTrustedSpecialTaskFunc100 is not a function

1:XFA:formulaire1[0]:#subform[0]:Bouton1[0]:click



-----------------

The code of the button :

event.target.SaveAsFunc(event.target);

-----------------



The JS code :



mySaveAsPO = app.trustPropagatorFunction(function(myDoc, path)

{

app.beginPriv();

var myDoc = event.target;

return retn = myDoc.saveAs(path);

app.endPriv();

});

SaveAsFunc = app.trustedFunction(function(myDoc, path)

{

app.beginPriv();



var av = formulaire1.subform1.departement_inclusion.rawValue



var g = "/c/PDF_Folder/" + av + ".pdf



var retn = mySaveAsPO(myDoc, g);



app.endPriv();

return retn;

});

-------------

Thanks for your help

Avatar

Avatar

pguerett

Avatar

pguerett

pguerett

12-01-2009

You will have to certify your document before the privilidged function will run. The certification allows the user to set up a trust - that he will allow script to run.

Avatar

Avatar

mipmater

Avatar

mipmater

mipmater

15-01-2009

I have certified my document but i always have the same message :



event.target.SaveAsFunc is not a function

1:XFA:formulaire1[0]:#subform[0]:Bouton1[0]:click



In the 'hierarchy', i've saved the script under Form1.



I don't understand this message : An error in the script, or the script is not found?



Thank's for your help

Avatar

Avatar

pguerett

Avatar

pguerett

pguerett

15-01-2009

Is SaveAsFunc a scripting object?

Avatar

Avatar

mipmater

Avatar

mipmater

mipmater

15-01-2009

Here is my code :



Button code : event.target.SaveAsFunc(event.target);



Script code (i created this script with a right click on Form1 in the hierarchy window, and wrote the code in the script editor)



mySaveAsPO = app.trustPropagatorFunction(function(myDoc, path)

{

app.beginPriv();

var myDoc = event.target;

return retn = myDoc.saveAs(path);

app.endPriv();

});

SaveAsFunc = app.trustedFunction(function(myDoc, path)

{

app.beginPriv();



var av = formulaire1.subform1.departement_inclusion.rawValue



var g = "/c/PDF_Folder/" + av + ".pdf



var retn = mySaveAsPO(myDoc, g);



app.endPriv();

return retn;

});



I don't know if it is the good process ?

Avatar

Avatar

pguerett

Avatar

pguerett

pguerett

15-01-2009

Don't do it in a scripting object to begin with. Get it to work outside of the script object ....then we will make a script object out of it.

Avatar

Avatar

mipmater

Avatar

mipmater

mipmater

15-01-2009

Ok, i must create a JS script : mySaveAsPO.js



but I do not understand how the pdf knows which script use ?

Avatar

Avatar

pguerett

Avatar

pguerett

pguerett

15-01-2009

That js script goes into a folder in the Acrobat installation and when Acrobat loads that script will be picked up (it is global in scope). Now you can reference it as you have been doing.