Skip to main content
Known Participant
July 30, 2019
Question

Clear form when I open a PDF

  • July 30, 2019
  • 3 replies
  • 6614 views

Hi everybody, is it possible to clear the fields of a form when I open a PDF document? How? Is it possible in Adobe Javascript?

​Regards

    This topic has been closed for replies.

    3 replies

    jane-e
    Community Expert
    Community Expert
    July 31, 2019

    Juanki  wrote

    is it possible to clear the fields of a form when I open a PDF document?

    Hi Juan,

    You don't need to write JavaScript, but you do need Acrobat, not the free Reader. Set a Page Property for Page 1 (or whatever page the PDF opens to) in either the Page Thumbnails panel or Organize Pages.

    Trigger: Page Open

    Action: Reset a form

    ~ Jane

    Here are the plans and pricing. If you don't want the annual plan, paid monthly, you can get a monthly plan for $25. There is also a seven-day free trial.

    Plans and pricing | Adobe Acrobat DC

    try67
    Community Expert
    Community Expert
    July 31, 2019

    That will reset the form each time you open page 1, not just when you open the file, though... For example, if you fill in some data, scroll to page 2 and then back to page 1, that data will be gone.

    Participant
    August 21, 2022

    Hi, I agree with the @try67 , it resets the form every time I move between pages. What is the best way to clear the form.  Thank You

    try67
    Community Expert
    Community Expert
    July 30, 2019

    Yes, it's possible to do that with a simple script, but you can't apply such a script with the free Reader. Do you have Acrobat? If so, which version?

    Adobe Employee
    July 30, 2019

    Acrobat DC SDK Documentation

    resetForm

    3.01

    https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/Acro12_MasterBook/JS_API_AcroJSPreface/Quick_bars.htm#HT_dirtyD

    https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/Acro12_MasterBook/JS_API_AcroJSPreface/Quick_bars.htm#HT_Column4F

    Resets the field values within a document. Resetting a field causes it to take on its default value (which, in the case of text fields, is usually blank).

    Note:If the form contains signature fields, signature rights https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/Acro12_MasterBook/JS_API_AcroJSPreface/Quick_bars.htm#HT_Column4are required to use the method in Adobe Reader.

    Parameters

    aFields

    (optional) An array specifying the fields to reset. If not present or null, all fields in the form are reset. You can include non-terminal fields in the array.

    Example 1

    Select fields to be reset and reset them.

       var fields = new Array();

       fields[0] = "P1.OrderForm.Description";

       fields[1] = "P1.OrderForm.Qty";

       this.resetForm(fields);

    The same fields can be reset using only one line of code:

       this.resetForm(["P1.OrderForm.Description","P1.OrderForm.Qty"]);

    Example 2

    This example shows how to reset a whole subtree. For example, if you pass “name” as part of the fields array, all name fields, such as name.first and name.last, are reset.

       this.resetForm(["name"]);

    Participant
    November 17, 2023

    Thanks, at Document level, below works if you are just wanting to reset one form field on open. Omitting the subtree brackets [ ]

    this.resetForm("fieldname");