Using JavaScript objects from Acrobat in Designer

In Designer, you can script against certain JavaScript objects in Acrobat by using the Acrobat scripting syntax. As a result, you can use the properties and methods of those objects on your form. For example, to display a message in the JavaScript Console from Acrobat, you can add the following script to the event of a form design object in Designer:

console.println("This message appears in the JavaScript Console.");

You can also have the form send itself by email by adding the following script to the click event of a button:

    var myDoc = event.target; 
    myDoc.mailDoc(true);
Note: In Designer, you must ensure that the scripting language for the event is set to JavaScript so that the script will execute correctly at run time.

You can also use references to the JavaScript objects in Acrobat in your reference syntax. For example, the following script gets the signed state of a signature field and takes an action based on the state:

    // Proceed if the current field is not signed. 
    var oState = 
        event.target.getField("form1[0].#subform[0].SignatureField1[0]") 
            .signatureValidate(); //Get the field's signed state. 
 
if (oState == 0) { 
... 
}
Note: This example uses a fully qualified reference syntax to reference the text For more information about referencing form design objects, see Referencing object properties and values .

When working with JavaScript from Acrobat in Designer, remember these points:

  • In Designer, use event.target to access the Doc JavaScript object from Acrobat. In Acrobat, the this object is used to reference the Doc object; however, in Designer, the this object refers to the form design object to which the script is attached.

  • The Script Editor has no statement completion for JavaScript objects from Acrobat. See the JavaScript for Acrobat API Reference .

  • The Doc method event.target.importTextData("file.txt") is not supported for dynamic XFA forms that have been certified.

    For more information about converting Acrobat scripting to Designer, see the article Converting Acrobat JavaScript for Use in Designer Forms in the Developer Center.

// Ethnio survey code removed