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

"Document Will Close" and Submit Form

cifs
Registered: May 30 2011
Posts: 3
Answered

Hi,
I have Acrobat 9/10 documents distributed to send Form data to a sharepoint server (Via the Acrobat Readers "Purple" Submit Form button). Many of my users fill the form in and then click X (exit).
 
I have some javascript which executes in the "Document Will Close" section and detects if the document is "dirty". If it is I prompt the user if they want to submit the data. If they do I want to Submit the form exactly as the "Purple" button does it.
 
I have tried everthing I could find on the Web and had no luck (see below, it never gets to the second alert). Does anyone have any ideas on how to execute the "Purple" Submit Form button?
 
Thanks.
 
if (this.dirty) {
var nRtn = app.alert("Entered data not saved. Do you want to save your entered data?",1,2,"Test");
if (nRtn = 1) {
this.dirty = false;
this.requiresFullSave = false;
this.SubmitForm("http://192.168.0.1/test#FDF",false,false);
app.alert("Test Prompt",1,2,"CompleteGP");
}
}
 

My Product Information:
Acrobat Pro 10.0.1, Windows
maxwyss
Registered: Jul 25 2006
Posts: 255
Look at the line where you evaluate nRtn. It is not comparing; it is assigning.

Hope this can help.

Max Wyss.

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Also, requiresFullSave is a Read-only property. You can't assign a value to it.

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

cifs
Registered: May 30 2011
Posts: 3
Sorry, I didn't update this problem. I have a program where the user requests a form to be filled, I run acrobat with an XFDF file I create with default values, it points to a PDF document. If the user makes changes and clicks the save button and exits my progrram parses the saved PDF document and stores the infomration in an XFDF file. If the user does not click save and just X, I want to save the document or XFDF information. One cannot execute menu item "Save". "SaveAs" saves it to some unknown directory, so I thought I would use Submit to sharepoint on address 127.0.0.1:xxxx in the "Will Close" javascript. I have this working on the Submit button (except I can't close the acrobat window, even with an FDF reply to closeDoc. Also it seems the Submit in the "Will close" does not execute until after the javascript completes (alert after Submit will show first). Then the connection is then made to my fake sharepoint and immediatly terminates because acrobat itself exits and then an error is displayed. So ... This is a very generic problem looking for a solution... I have tried everything except Giving adobe huge sums on money). This is now probably the wrong forum... It looks like my only solution is to try to set or determine the default location that the SaveAs uses.

Send from my IPAD while on vacation with out code or manuals near so some routines might be spelled incorrectlt :-)
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Bottom line is this: You should not use the WillClose event for any of these actions (saving, exporting, submitting, etc.) It's risky and is not recommended.
What you can do is alert the user that the changes they made are going to be lost if they don't save/submit.

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

cifs
Registered: May 30 2011
Posts: 3
Accepted Answer
try67 wrote:
What you can do is alert the user that the changes they made are going to be lost if they don't save/submit.
Yes that is what I do, but my message has to tell them to hit Cancel on the next message box and then click the save icon and then they can exit.

Here is my solution (which I hate):

My main process every 200 ms checks for a SaveAs dialog from acrobat and then auto fills it in with a know file name location which is guarenteed to not exist (stop the Replace dialog) and simulates an Ok. I then copy the new file over the existing one. I also have code which parses the PDF document and produces an XFDF file. Job done. Well Hack done.