I have seen a number of posts on this...but have not actually been able to get it to work (due to my very limited knowledge of javascript). I currently have a form that uses the script shown below to save and then email the form...however, what I want to achieve is the following:
1- User clicks "Save and Email File" button
2- Window's prompt appears with predetermined name (i.e. field1.pdf) during the save function (user can modify the name and select location).
3- Once the file saves it is then delivered to email client with email subject and body predetermined based on data in the form.
I have everything correct except for the predetermined name that appears during the save process.
Currently I have the following (and it does work for me):
---
app.execMenuItem("SaveAs");
var Comment = field1.rawValue;
if (field1.rawValue == null){ Comment = "New"} else {Comment = field1.rawValue};
event.target.submitForm({cURL:"mailto:myemail [at] anymail [dot] com?subject="+Comment+" Submission &body=Please review this submission: "+Comment+"",cSubmitAs:"PDF",cCharset:"utf-8"});
---
Based on some of the posts (thanks to Thom Parker, WindJack Solutions) it looks as if I should be using the following:
"app.response()" function and the "doc.saveAs()" function
Issue here is I dont not know enough about how to get this properly programmed in my "click" event to get them to work. Looking for something I can just cut and paste (with minor modification to field names, etc).
Can anyone help me?
P.S. Currently using Acrobat Pro 9.0 (LiveCycle Designer) with a target audience using Acrobat Reader 7.1 and up on both Window and Mac machines. File will have "Extended Features for Reader" enabled.
To change the name of the file by JavaScript you can not use the "execMenuItem()" method but should use the "saveAs()" method:
var myDoc = event.target;
myDoc.saveAs();
Which will allow one to specifiy the path and file name.
Be aware there are a number of security restrications that may have to be delt with by a user of your form. This information is contained in the Acrobat JS API Reference.
George Kaiser