Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Button 'SaveAs'

mipmater
Level 2
Level 2
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...
7 Replies
pguerett
Level 10
Level 10
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).
Thorlabs_HL
Level 2
Level 2

Hi,

I found this thread by accident. I have one question about the SaveAs. I want to use app.execMenuItem("SaveAs"). But I also want to create a default name to save this document. I have a text field "serial number" that will be filled out by the user and I want to use this serial number as document name. How can I realise it? - I'm a Script-Newbie.

Dennis

thorlabs_hl

pguerett
Level 10
Level 10

No can do ......you cannot automatically save something without the user entering the file name unless you certify the document which will bring in a new set of issues.

Paul

Thorlabs_HL
Level 2
Level 2

Hi,

I don't want to autosave. It was mentioned in this thread that this is not possible. I want to suggest the user a suitable file name. The user can edit it if he want. It is like I'm saying: "This would be a good name. You should go with it."

Dennis

thorlabs_hl

pguerett
Level 10
Level 10

I understand but the command does not work that way. The command basically will press the File /SaveAs menu item.

Paul

Thorlabs_HL
Level 2
Level 2

Ah. OK. I understand. But is there an other way to realize it. A easy way? I'm a newbie. If there is no way I just place a note next to the save button.

Dennis

thorlabs_hl

Thorlabs_HL
Level 2
Level 2

Thanks for the help. Even this "no" is a helpful answer for me. I stay with my note next to the save button.

Dennis

thorlabs_hl

mipmater
Level 2
Level 2
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
pguerett
Level 10
Level 10
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.
mipmater
Level 2
Level 2
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
mipmater
Level 2
Level 2
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 ?
pguerett
Level 10
Level 10
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.
mipmater
Level 2
Level 2
Ok, i must create a JS script : mySaveAsPO.js



but I do not understand how the pdf knows which script use ?
pguerett
Level 10
Level 10
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.
mipmater
Level 2
Level 2
Ok, i know why i've got this error, I had forgotten a quote in the code.



now, i have this error :



formulaire1 is not defined

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



thank you for your help and patience
mipmater
Level 2
Level 2
Sorry but i can't resolve this error



formulaire1 is not defined

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



In my hierarchy, there is :

formulaire1

subform

item1

item2

...



is this code wrong :

var av = formulaire1.subform1.departement_inclusion.rawValue



And a last question,

is it possible to save a PDF form, on a simple PDF (a picture of the form).



Thanks for your help
pguerett
Level 10
Level 10
Its hard to tell what is wrong without seeing the form and getting the code in context. Send it to livecycle8@gmail.com and I will have a look.



You can not save as an image PDF out of Designer. You would create the PDF, then open it in Acrobat then you can export as an image.