These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

SUbmitting Form Data as CSV when client presses submit button on Form

pAtt
Registered: Jan 16 2008
Posts: 4
Answered

I have a form that I created using Adobe Acrobat Pro 9. I did all the fields using the form tools in Acrobat not designer.

Currently in the submit button I am running a java script that checks to make sure all the required fields are filled in before allowing the form to be submitted. The output format is currently XML.

I have read in other forums that this is possible using PHP and formmail and things I don't have. I am hoping there is a script I could put in my submit button that will make this happen. This is the script that is currently sitting in the Mouse Up action of the Submit button. Notice at the bottom it is currently set to XML. My client seems to think if she can think it, then it should be able to be done. So I am praying for a miracle here. Thanks in advance. I am self taught on the javascript through trial and error and realize what I have below could probably done in a different way, but this way makes sense to me.

var a = this.getField("Name")
var b = this.getField("State or Province")
var c = this.getField("Country")
var d = this.getField("E-mail address")
var e = this.getField("Research interest")
var f = this.getField("Interviewee Name 1")

if ((a.value == a.defaultValue))
{
a.setFocus()
app.alert("I'm sorry this field is required. Please provide your name.");

exit
}

else
if ((b.value == b.defaultValue))
{
b.setFocus()
app.alert("I'm sorry this field is required. Please provide your State or Province.");

exit
}

else
if ((c.value == c.defaultValue))
{
c.setFocus()
app.alert("I'm sorry this field is required. Please provide your Country.");

exit
}
else
if ((d.value == d.defaultValue))
{
d.setFocus()
app.alert("We're sorry, but the email field is required. Please provide a valid e-mail address. Note that delivery of transcripts is available only online, and for access you must provide an e-mail address.");

exit
}
else
if ((e.value == e.defaultValue))
{
e.setFocus()
app.alert("I'm sorry this field is required. Please provide a brief description of your research interest in the transcrip(s) you are requesting.");

exit
}
else
if ((f.value == f.defaultValue))
{
f.setFocus()
app.alert("I'm sorry this field is required. Please provide the name of the interviewee.");

exit
}
else

this.submitForm({
cURL: "mailto:some_email [at] someplace [dot] com",
cSubmitAs: "XML"
});

My Product Information:
Acrobat Pro Extended 9.3.1, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Your code looks very nice. there are no problems the way you've setup the validation. But unfortunately CSV just isn't a format that can be submitted directly from a PDF. I suppose your client would like CSV because it can be imported directly into an Excel file, or some other data tool? XML is of course very flexible and well understood by most software so there should be a way form them to use it.


Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

try67
Expert
Registered: Oct 30 2008
Posts: 2398
What you can do is create the CSV contents, and send it as the plain-text body of the email (use app.mailMsg instead of this.submitForm).
The recipient can then copy the text to a file, and save it with a CSV extension.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Hey Try67, that's a good one. It was actually quite common on old mainframe systems to route data and commands as email contents. You could even create an Outlook VBA add-in to grab the data and save it somewhere.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

pAtt
Registered: Jan 16 2008
Posts: 4
thanks, guys...this might be out of my league. I was able to persuade the client that I wasn't able to do it.
gw2
Registered: Dec 12 2010
Posts: 3
Hey Guys,

I was able to get this java to work with app.mailMsg with Adobe Acrobat Pro 9 Extended but will not execute the same script in Adobe Reader 9. Another forms forum here informs me that the java properties of app.mailMsg are not supported in Adobe Reader 9. Looks like I have to come up with another way of using this code on a button. Any ideas ? - Basic idea = User fills in form > Hits submit button > Form data is displayed in body of email for submission to Help Desk
Thanks,
GW

Here's the code:
var to = this.getField("to");

var statetagv = this.getField("st_tag");

var pov = this.getField("po_num");
var unitv = this.getField("unit_num");
var loccodev = this.getField("loc_code");
var modelv = this.getField("model_num");
var serialv = this.getField("serial_num");

var brandv = this.getField("brand_comp");

var deptv = this.getField("dept");

var bldlocationv = this.getField("located");

var softofficev = this.getField("soft_msoffice");

var softsymantecv = this.getField("soft_symantec");

var softxpvistav = this.getField("soft_xpvista");

var namev = this.getField("Name");

var phonenumv = this.getField("phone_num");

var emailv = this.getField("e_mail");

var subbyv = this.getField("sub_by");


var subject = "New PC Notification"

var emailBody = "";
emailBody += "NEW PC\r\n";
emailBody += "STATE TAG NUMBER: " + statetagv.value + "\r\n";
emailBody += "\r\n";
emailBody += "PURCHASE ORDER:";
emailBody += pov.value + "\r\n";
emailBody += "UNIT NUMBER:" + unitv.value + "\r\n";
emailBody += "LOC CODE:" + loccodev.value + "\r\n";
emailBody += "MODEL:" + modelv.value + "\r\n";
emailBody += "SERIAL NUMBER:";
emailBody += serialv.value + "\r\n";
emailBody += "BRAND:";
emailBody += brandv.value + "\r\n";
emailBody += "\r\n";
emailBody += "DEPARTMENT:";
emailBody += deptv.value + "\r\n";
emailBody += "LOCATION:" + bldlocationv.value + "\r\n";
emailBody += "\r\n";
emailBody += "SOFTWARE MS OFFICE:" + softofficev.value + "\r\n";
emailBody += "SOFTWARE SYMANTEC:" + softsymantecv.value + "\r\n";
emailBody += "SOFTWARE MS XP OR VISTA:" + softxpvistav.value + "\r\n";
emailBody += "\r\n";
emailBody += "NAME:" + namev.value + "\r\n";
emailBody += "PHONE:" + phonenumv.value + "\r\n";
emailBody += "EMAIL:" + emailv.value + "\r\n";
emailBody += "\r\n";
emailBody += "SUBMITTED BY:";
emailBody += subbyv.value + "\r\n";




app.mailMsg({

bUI: true,

cTo: to.value,

cSubject: subject,

cMsg: emailBody

} );

GW

maxwyss
Registered: Jul 25 2006
Posts: 255
According to the Acrobat JavaScript documentation (which you definitely should get), the app.mailMsg() method is not available for Reader (not even with ARES Extended Rights...) ... complaints to be directed at Adobe...

HTH