Reset PDF form on open or close?


I’m trying to find a way to avoid making my form users click the “reset form” button to make sure the form data gets cleared when they’re done with the form (like after they hit the print button, but not because they hit the print button).

We’re currently using a .fdf “solution” to handle this, but we’re starting to get negative feedback from customers who can’t open files with this extension. I’m not sure why they’re having trouble, but I can’t reproduce the error. Still, if there’s a way to reset the form when it’s opened or closed just using Acrobat Pro and some JavaScript, that would make me a very happy camper.

our .fdf looks like this:

1 0 obj
/FDF << /JavaScript << /After (this.resetForm\\(\\))>>
/F (http://myFormsServer.pdf)>>
/Root 1 0 R


Maybe this is the wrong place to post? If not here, where? I’ve hit my usual help-seeking haunts including (of course) google already and come up dry (although I’m behind a fairly strict firewall so I can’t put the word “hack” into a search string). Maybe I missed it when I searched SPF?

Well, i’ve got an answer to my issue. i’m going to log it here in case it will help someone else.

To Disable the Caching in PDF Forms

Forms saved in PDF format with form fields that may be completed online are sometimes cached by the browser. That is, when a user completes a PDF form online, the information entered in the form will appear the next time the form is opened in that browser. The information should be cleared the next time the form is opened for information privacy, especially if the form might be completed at a public workstation. Using Adobe Acrobat 6.0 Professional, follow the steps below to disable caching (storing) of information entered on the form.

i. Add a Document-Level JavaScript:

Click Advanced, point to JavaScript, and then click Document JavaScripts. A Java Script Functions dialog box will open.
In the Script Name field type init and click the Add button.
Delete the automatically generated text that is displayed in the script window, and copy and paste or type the following code in the exact format (line wraps are fine), click OK, then click Close:

var bReset = false;
var url_re = /^http:\/\/|^ftp:\/\//i;
var isInBrowser = false;
if (this.external && url_re.test(this.path)) isInBrowser = true;
ii. Add a Page Open JavaScript action:

Click View, point to Navigation Tabs, and then click Pages.
Select a page thumbnail then click the Options button.
Click Page Properties from the Options menu.
In the Page Properties dialog box, click the Actions tab.
From the Select Trigger drop down list select Page Open.
From the Select Action drop down list select Run a JavaScript.
Click the Add button.
A JavaScript Editor dialog box will open, copy and paste the following code in the exact format (line wraps are fine), click OK, then click Close:

if (!bReset && isInBrowser)
{ this.resetForm();
bReset = true; }
In addition, because a user may have Javascript disabled on their browser, you may want to add a button on the form so a user may manually clear all the form fields.