Search code examples
javascriptpdfdom-eventsresetacrobat

How to reset the complete document after opening it?


I want to reset the complete form after opening it.

I have tried this:

page.open = this.resetForm();

But it doesn't work. I'm using Acrobat Pro DC.


Solution

  • How to reset a form when opening:

    You can follow these instructions (note that the description is for Acrobat DC; in older versions, it is similar).

    1. Open your document in Acrobat.

    2. Display the Pages in the Left Hand Panel.

    3. Select the Context menu of the first page (or the page which has been specified in the document properties to open).

    4. Select Page Properties… from the context menu

    5. In the dialog which appears, select the Actions tab

    6. Select Trigger Page Open

    7. Select Action Run a JavaScript

    8. Click Add

    9. In the editor window which appears enter the following code:

    If your form is a single page document:

    this.resetForm() ;
    

    If your form is a multiple page document:

    if (loaded == false) {
    this.resetForm() ;
    loaded = true ;
    }
    
    1. Confirm the dialogs until you are back in the document. If you have a single-page document, save it, and you are done.

    If you have a multi-page document, proceed as follows:

    1. Switch to the Tools window, and select the JavaScript Tool

    2. Select Document JavaScripts in the toolbar

    3. In the dialog which opens enter a name for your script, such as loading

    4. Click Add…

    5. In the editor window which opens, delete all the selected text.

    Then enter this line of code:

    var loaded = false ;
    
    1. Confirm until you are back to the document.

    2. Save the document

    And that should do it.