Field methods

browseForFileToSubmit

deleteItemAt

setItems

buttonGetCaption

getArray

setLock

buttonGetIcon

getItemAt

signatureGetModifications

buttonImportIcon

getLock

signatureGetSeedValue

buttonSetCaption

insertItemAt

signatureInfo

buttonSetIcon

isBoxChecked

signatureSetSeedValue

checkThisBox

isDefaultChecked

signatureSign

clearItems

setAction

signatureValidate

defaultIsChecked

setFocus

 

browseForFileToSubmit

5.0

D 

 

 

If invoked on a text field for which the fileSelect flag is set (checked), opens a standard file-selection dialog box. The path entered through the dialog box is automatically assigned as the value of the text field.

If invoked on a text field in which the fileSelect flag is clear (unchecked), an exception is thrown.

Example

The following code references a text field with the file select flag checked. It is a mouse-up action of a button field.

   var f = this.getField("resumeField");

   f.browseForFileToSubmit();

buttonGetCaption

5.0

 

 

 

Gets the caption associated with a button.

Use buttonSetCaption to set the caption.

Parameters

nFace 

(optional) If specified, gets a caption of the given type:

0 — (default) normal caption

1 — down caption

2 — rollover caption

Returns

The caption string associated with the button.

Example

This example places pointing arrows to the left and right of the caption on a button field with icon and text.

   // A mouse enter event

   event.target.buttonSetCaption("=> "+ event.target.buttonGetCaption()

      +" <=");

   

   // A mouse exit event

   var str = event.target.buttonGetCaption();

   str = str.replace(/=> | <=/g, "");

   event.target.buttonSetCaption(str);

The same effect can be created by having the same icon for rollover and the same text, with the arrows inserted, for the rollover caption. This approach would be slower and cause the icon to flicker. The above code gives a very fast and smooth rollover effect because only the caption is changed, not the icon.

buttonGetIcon

5.0

 

 

 

Gets the Icon object of a specified type associated with a button.

See also the buttonSetIcon method for assigning an icon to a button.

Parameters

nFace 

(optional) If specified, gets an icon of the given type:

0 — (default) normal icon

1 — down icon

2 — rollover icon

Returns

The Icon object.

Example

   // Swap two button icons.

   var f = this.getField("Button1");

   var g = this.getField("Button2");

   var temp = f.buttonGetIcon();

   f.buttonSetIcon(g.buttonGetIcon());

   g.buttonSetIcon(temp);

See also buttonSetIcon and buttonImportIcon.

buttonImportIcon

3.01

 

S 

X 

Imports the appearance of a button from another PDF file. If neither optional parameter is passed, the user is prompted to select a file.

See also buttonGetIcon, buttonSetIcon, addIcon, getIcon, importIcon, and removeIcon.

Note:(Acrobat 8.0) If cPath is specified, this method can only be executed during batch and console events. See Privileged versus non-privileged context for details. The event object contains a discussion of JavaScript events.

Parameters

cPath 

(optional, Acrobat 5.0) The device-independent path for the file.

Beginning with Acrobat 6.0, Acrobat first attempts to open cPath as a PDF file. On failure, Acrobat tries to convert the file to PDF from one of the known graphics formats (BMP, GIF, JPEG, PCX, PNG, TIFF) and then import the converted file as a button icon.

nPage 

(optional, Acrobat 5.0) The 0-based page number from the file to turn into an icon. The default is 0.

Returns

An integer, as follows:

1 — The user cancelled the dialog

0 — No error

-1 — The selected file could not be opened

-2 — The selected page was invalid

Example (Acrobat 5.0)

It is assumed that we are connected to an employee information database. We communicate with the database using the ADBC object and related objects. An employee’s record is requested and three columns are utilized, FirstName, SecondName, and Picture. The Picture column, from the database, contains a device-independent path to the employee’s picture, stored in PDF format. The script might look like this:

   var f = this.getField("myPicture");

   f.buttonSetCaption(row.FirstName.value + " " + row.LastName.value);

   if (f.buttonImportIcon(row.Picture.value) != 0)

      f.buttonImportIcon("/F/employee/pdfs/NoPicture.pdf");

The button field “myPicture” has been set to display both icon and caption. The employee’s first and last names are concatenated to form the caption for the picture. Note that if there is an error in retrieving the icon, a substitute icon can be imported.

buttonSetCaption

5.0

D 

 

 

Sets the caption associated with a button.

Use buttonGetCaption to get the current caption.

See buttonAlignX, buttonAlignY, buttonFitBounds, buttonPosition, buttonScaleHow, and buttonScaleWhen for details on how the icon and caption are placed on the button face.

Parameters

cCaption 

The caption associated with the button.

nFace 

(optional) If specified, sets a caption of the given type:

0 — (default) normal caption

1 — down caption

2 — rollover caption

Example

   var f = this.getField("myButton");

   f.buttonSetCaption("Hello");

buttonSetIcon

5.0

D 

 

 

Sets the icon associated with a button.

See buttonAlignX, buttonAlignY, buttonFitBounds, buttonPosition, buttonScaleHow, and buttonScaleWhen for details on how the icon and caption are placed on the button face.

Use either buttonGetIcon or doc.getIcon to get an Icon object that can be used for the oIcon parameter of this method.

Note:This method must be executed from script embedded within the document. Executing script containing buttonSetIcon in the console of the Adobe Reader, for example, will throw a NotAllowedError exception.

Parameters

oIcon 

The Icon object associated with the button.

nFace 

(optional) If specified, sets an icon of the given type:

0 — (default) normal icon

1 — down icon

2 — rollover icon

Example

This example takes every named icon in the document and creates a list box using the names. Selecting an item in the list box sets the icon with that name as the button face of the field “myPictures”. What follows is the mouse-up action of the button field “myButton”.

   var f = this.getField("myButton")

   var aRect = f.rect;

   aRect[0] = f.rect[2];             // Place list box relative to the

   aRect[2] = f.rect[2] + 144;        // position of "myButton"

   var myIcons = new Array();

   var l = addField("myIconList", "combobox", 0, aRect);

   l.textSize = 14;

   l.strokeColor = color.black;

   for (var i = 0; i < this.icons.length; i++)

      myIcons[i] = this.icons[i].name;

   l.setItems(myIcons);

   l.setAction("Keystroke",

      'if (!event.willCommit) {\r\t'

      + 'var f = this.getField("myPictures");\r\t'

      + 'var i = this.getIcon(event.change);\r\t'

      + 'f.buttonSetIcon(i);\r'

      + '}');

The named icons themselves can be imported into the document through an interactive scheme, such as the example given in addIcon or through a batch sequence.

See also buttonGetCaption for a more extensive example.

checkThisBox

5.0

D 

 

F 

Checks or unchecks the specified widget.

Only check boxes can be unchecked. A radio button cannot be unchecked using this method, but if its default state is unchecked (see defaultIsChecked) it can be reset to the unchecked state using the resetForm. method of the Doc.

Note:For a set of radio buttons that do not have duplicate export values, you can set the value to the export value of the individual widget that should be checked (or pass an empty string if none should be).

Parameters

nWidget 

The 0-based index of an individual check box or radio button widget for this field. The index is determined by the order in which the individual widgets of this field were created (and is unaffected by tab-order).

Every entry in the Fields panel has a suffix giving this index; for example, MyField #0.

bCheckIt 

(optional) Specifies whether the widget should be checked. The default is true.

Example

Check a check box.

   var f = this.getField("ChkBox");

   f.checkThisBox(0,true);

clearItems

4.0

D 

 

F 

Clears all the values in a list box or combo box.

Related methods and properties include numItems, getItemAt, deleteItemAt, currentValueIndices, insertItemAt and setItems.

Example

Clear the field “myList” of all items.

   this.getField("myList").clearItems();

defaultIsChecked

5.0

D 

 

 

Sets the specified widget to be checked or unchecked by default.

Note:For a set of radio buttons that do not have duplicate export values, you can set the defaultValue to the export value of the individual widget that should be checked by default (or pass an empty string if none should be checked).

Parameters

nWidget 

The 0-based index of an individual radio button or check box widget for this field. The index is determined by the order in which the individual widgets of this field were created (and is unaffected by tab-order).

Every entry in the Fields panel has a suffix giving this index (for example, MyField #0).

bIsDefaultChecked 

(optional) If true (the default), the widget should be checked by default (for example, when the field gets reset). If false, it should be unchecked by default.

Returns

true on success.

Example

Change the default of “ChkBox” to checked, then reset the field to reflect the default value.

   var f = this.getField("ChkBox");

   f.defaultIsChecked(0,true);

   this.resetForm(["ChkBox"]);

deleteItemAt

4.0

D 

 

F 

Deletes an item in a combo box or a list box.

For a list box, if the current selection is deleted, the field no longer has a current selection. If this method is invoked again on the same field and no parameter is specified, unexpected behavior can result because there is no current selection to delete. Therefore, it is important to make a new selection (such as by using the currentValueIndices method) for the method to behave as documented.

Parameters

nIdx 

(optional) The 0-based index of the item in the list to delete. If not specified, the currently selected item is deleted.

Example

Delete the current item in the list, then select the top item in the list.

   var a = this.getField("MyListBox");

   a.deleteItemAt();              // Delete current item, and...

   a.currentValueIndices = 0;     // select top item in list

getArray

3.01

 

 

 

Gets the array of terminal child fields (that is, fields that can have a value) for this Field object, the parent field.

Returns

An array of Field objects

Example

Make a calculation of the values of the child fields of the parent field.

   // f has 3 children: f.v1, f.v2, f.v3

   var f = this.getField("f");

   var a = f.getArray();

   var v = 0.0;

   for (j =0; j < a.length; j++) v += a[j].value;

   // v contains the sum of all the children of field "f"

getItemAt

3.01

 

 

 

Gets the internal value of an item in a combo box or a list box.

The number of items in a list can be obtained from numItems. See also insertItemAt, deleteItemAt, clearItems, currentValueIndices and setItems.

Parameters

nIdx 

The 0-based index of the item in the list or -1 for the last item in the list.

bExportValue 

(optional, Acrobat 5.0) Specifies whether to return an export value:

  • If true (the default), if the item has an export value, it is returned. If there is no export value, the item name is returned.

  • If false, the method returns the item name.

Returns

The export value or name of the specified item.

Example

In the two examples that follow, assume there are three items on “myList”: “First”, with an export value of 1; “Second”, with an export value of 2; and “Third”, with no export value.

   // Returns value of first item in list, which is 1

   var f = this.getField("myList");

   var v = f.getItemAt(0);

The following example shows the use of the second optional parameter. By setting it to false, the item name (face value) can be obtained, even if there is an export value.

   for (var i=0; i < f.numItems; i++)

      console.println(f.getItemAt(i,true) + ":  " + f.getItemAt(i,false));

The output to the console reads:

   1:            First

   2:            Second

   Third:        Third

getLock

6.0

 

 

 

Gets a Lock object, a generic object that contains the lock properties of a signature field.

See also setLock.

Returns

The Lock object for the field.

insertItemAt

3.01

D 

 

F 

Inserts a new item into a combo box or a list box.

Related methods and properties include numItems, getItemAt, deleteItemAt, clearItems, currentValueIndices and setItems.

Parameters

cName 

The item name that will appear in the form.

cExport 

(optional) The export value of the field when this item is selected. If not provided, the cName is used as the export value.

nIdx 

(optional) The index in the list at which to insert the item. If 0 (the default), the new item is inserted at the top of the list. If –1, the new item is inserted at the end of the list.

Example

   var l = this.getField("myList");

   l.insertItemAt("sam", "s", 0); /* inserts sam to top of list l */

isBoxChecked

5.0

 

 

 

Determines whether the specified widget is checked.

Note:For a set of radio buttons that do not have duplicate export values, you can get the value, which is equal to the export value of the individual widget that is currently checked (or returns an empty string, if none is).

Parameters

nWidget 

The 0-based index of an individual radio button or check box widget for this field. The index is determined by the order in which the individual widgets of this field were created (and is unaffected by tab-order).

Every entry in the Fields panel has a suffix giving this index, for example, MyField #0.

Returns

true if the specified widget is currently checked, false otherwise.

Example

Determine the state of the check box and report back with an alert box.

   var f = this.getField("ChkBox");

   var cbStatus = (f.isBoxChecked(0)) ? " " : " not ";

   app.alert("The box is" + cbStatus + "checked");

isDefaultChecked

5.0

 

 

 

Determines whether the specified widget is checked by default (for example, when the field gets reset).

Note:For a set of radio buttons that do not have duplicate export values, you can get the defaultValue, which is equal to the export value of the individual widget that is checked by default (or returns an empty string, if none is).

Parameters

nWidget 

The 0-based index of an individual radio button or check box widget for this field. The index is determined by the order in which the individual widgets of this field were created (and is unaffected by tab-order).

Every entry in the Fields panel has a suffix giving this index, for example, MyField #0.

Returns

true if the specified widget is checked by default, false otherwise.

Example

Determine if the specified check box is checked by default.

   var f = this.getField("ChkBox");

   var cbStatus = (f.isDefaultChecked(0)) ? "Checked" : "Unchecked";

   app.alert("The Default: " + cbStatus);

setAction

5.0

D 

 

X 

Sets the JavaScript action of the field for a given trigger.

Related methods are the Bookmark object setAction method and the Doc methods setAction, addScript, and setPageAction.

Note:This method will overwrite any action already defined for the chosen trigger.

Parameters

cTrigger 

A string that sets the trigger for the action. Values are:

  MouseUp
  MouseDown
  MouseEnter
  MouseExit
  OnFocus
  OnBlur
  Keystroke
  Validate
  Calculate
  Format
 

For a list box, use the Keystroke trigger for the Selection Change event.

cScript 

The JavaScript code to be executed when the trigger is activated.

Example

Set up a button field with addField, add some properties, and a mouse-up action using setAction.

   var f = this.addField("actionField", "button", 0 , [20, 100, 100, 20]);

   f.setAction("MouseUp", "app.beep(0);");

   f.delay = true;

      f.fillColor = color.ltGray;

      f.buttonSetCaption("Beep");

      f.borderStyle = border.b;

      f.lineWidth = 3;

      f.strokeColor = color.red;

      f.highlight = highlight.p;

   f.delay = false;

setFocus

4.05

 

 

 

Sets the keyboard focus to this field. This can involve changing the page that the user is currently on or causing the view to scroll to a new position in the document. This method brings the document in which the field resides to the front, if it is not already there.

See also bringToFront.

Example

Search for a certain open document, then focus on the field of interest. This script uses app.activeDocs, which requires the disclosed property of the documents to be true, or the script to be run during console, batch or menu events.

   var d = app.activeDocs;

   for (var i = 0; i < d.length; i++) {

      if (d[i].info.Title == "Response Document") {

         d[i].getField("name").value="Enter your name here: "

         // also brings the doc to front.

         d[i].getField("name").setFocus();

         break;

      }

   }

setItems

4.0

D 

 

F 

Sets the list of items for a combo box or a list box.

Related methods and properties include numItems, getItemAt, deleteItemAt, currentValueIndices and clearItems.

Parameters

oArray 

An array in which each element is either an object convertible to a string or another array:

  • For an element that can be converted to a string, the user and export values for the list item are equal to the string.

  • For an element that is an array, the array must have two subelements convertible to strings, where the first is the user value and the second is the export value.

Examples

Get various fields (combo or list) and set items in the list using various techniques.

   var l = this.getField("ListBox");

   l.setItems(["One", "Two", "Three"]);

   

   var c = this.getField("StateBox");    

   c.setItems([["California", "CA"],["Massachusetts", "MA"],

      ["Arizona", "AZ"]]);

   

   var c = this.getField("NumberBox");

   c.setItems(["1", 2, 3, ["PI", Math.PI]]);

setLock

6.0

D 

S 

X 

Controls which fields are to be locked when a signature is applied to this signature field. No modifications can be made to locked fields. If the signature is cleared, all fields that were locked become unlocked. The property settings can be obtained using getLock.

Note:The method can be executed during a batch, application initialization, or console event. See Privileged versus non-privileged context for details.

This method cannot be applied to a field that is in a document that is already signed.

Parameters

oLock 

A Lock object containing the lock properties.

Returns

true if successful, otherwise false or throws an exception.

Lock Object

A generic JavaScript object containing lock properties. This object is passed to setLock and returned by getLock for a signature field. It contains the following properties.

Property

Type

Access

Description

action 

String

R/W

The language-independent name of the action. Values are:

All — All fields in the document are to be locked.

Include — Only the fields specified in fields are to be locked.

Exclude — All fields except those specified in fields are to be locked.

fields 

Array of Strings

R/W

An array of strings containing the field names. Required if the value of action is Include or Exclude.

signatureGetModifications

7.0

 

 

 

Returns an object containing information on modifications that have been made to the document after the signature field was signed. The information includes only the difference between the current and signed state of the document. Transient objects, such as objects added after the signature but then subsequently deleted, are not reported.

Returns

An object containing modification information. The object has the following properties:

Property

Type

Description

formFieldsCreated 

Array of Field objects

Array of form fields created after signing.

formFieldsDeleted 

Array of Generic objects

Array of form fields deleted after signing. Each generic object in the array is a string of the form name : type.

formFieldsFilledIn 

Array of Field objects

Array of form fields filled in after signing.

formFieldsModified 

Array of Field objects

Array of form fields modified after signing. In this context, form field fill-in does not constitute modification.

annotsCreated 

Array of Annotation 
objects

Array of annotations created after signing. If the annotation is transient (for example, a dynamically created pop-up), the corresponding element of the array is a string of the form author : name : type.

annotsDeleted 

Array of Generic objects

Array of annotations deleted after signing. Each generic object in the array is of the form author : name : type.

annotsModified 

Array of Annotation 
objects

Array of annotations modified after signing. If the annotation is transient (for example, a dynamically created pop-up), the corresponding element of the array is a string of the form author : name : type.

numPagesCreated 

Integer

Number of pages added after signing.

numPagesDeleted 

Integer

Number of pages deleted after signing.

numPagesModified 

Integer

Number of pages whose content has been modified after signing (add/delete/modify of annotations/form fields are not considered as page modification for this purpose).

spawnedPagesCreated 

Array of Strings

List of pages spawned after signing. For each spawned page, the name of the source template is provided.

spawnedPagesDeleted 

Array of Strings

List of spawned pages deleted after signing. For each spawned page, the name of the source template is provided.

spawnedPagesModified 

Array of Strings

List of spawned pages modified after signing. For each spawned page, the name of the source template is provided.

Example

Write modification information back to the console.

   var sigField = this.getField( "mySignature" );

   var sigMods = sigField.signatureGetModifications();

   

   var formFieldsCreated = sigMods.formFieldsCreated;

   for( var i = 0; i < formFieldsCreated.length; i++ )

      console.println( formFieldsCreated[i].name );

   

   var formFieldsDeleted = sigMods.formFieldsDeleted;

   for( var i = 0; i < formFieldsDeleted.length; i++ )

      console.println( formFieldsDeleted[i].name );

   

   var formFieldsFilledIn = sigMods.formFieldsFilledIn;

   for( var i = 0; i < formFieldsFilledIn.length; i++ )

      console.println( formFieldsFilledIn[i].name );

   

   var formFieldsModified = sigMods.formFieldsModified;

   for( var i = 0; i < formFieldsModified.length; i++ )

      console.println( formFieldsModified[i].name );

   

   var spawnedPages = sigMods.spawnedPagesCreated;

   for( var i = 0; i < spawnedPages.length; i++ )

      console.println( spawnedPages[i] );

   

   console.println( sigMods.numPagesDeleted );

signatureGetSeedValue

6.0

 

 

 

Returns a SeedValue object that contains the seed value properties of a signature field. Seed values are used to control properties of the signature, including the signature appearance, reasons for signing, and the person.

See signatureSetSeedValue.

Returns

A SeedValue object.

Example

Access the seed value for a signature field.

   var f = this.getField( "sig0" );

   var seedValue = f.signatureGetSeedValue();

   // displays the seed value filter and flags

   console.println( "Filter name:" + seedValue.filter);

   console.println( "Flags:" + seedValue.flags);

   // displays the certificate seed value constraints

   var certSpec = seedValue.certspec;

   console.println( "Issuer:" + certspec.issuer);

signatureInfo

5.0

 

 

 

Returns a SignatureInfo object that contains the properties of the signature. The object is a snapshot of the signature at the time that this method is called. A security handler may specify additional properties that are specific to the security handler.

Note:There are no restrictions on when this method can be called. However, the specified security handler, oSig, may not always be available. See the security.getHandler method for details.

Some properties of a signature handler, for example, certificates (a property of the SignatureInfo object), may return a null value until the signature is validated. Therefore, signatureInfo should be called again after signatureValidate.

Parameters

oSig 

(optional) The SecurityHandler object to use to retrieve the signature properties. If not specified, the security handler is determined by the user preferences. (It is usually the handler that was used to create the signature.)

Returns

A SignatureInfo object that contains the properties of the signature. This type of object is also used when signing signature fields, signing FDF objects, or with the FDF object signatureValidate method.

Example

Access SignatureInfo object properties.

   // Get all info

   var f = getField( "Signature1" );

   f.signatureValidate();

   var s = f.signatureInfo();

   console.println( "Signature Attributes:" );

   for(i in s) console.println( i + " = " + s[i] );

   

   // Get particular info

   var f = this.getField("Signature1"); // uses the ppklite sig handler

   var Info = f.signatureInfo();

   // Some standard signatureInfo properties

   console.println("name = " + Info.name);         

   console.println("reason = " + Info.reason);

   console.println("date = " + Info.date);

   

   // Additional signatureInfo properties from PPKLite

   console.println("contact info = " + Info.contactInfo);

   

   // Get the certificate; first (and only) one

   var certificate = Info.certificates[0];

   

   // Common name of the signer

   console.println("subjectCN = " +  certificate.subjectCN);

   console.println("serialNumber = " +  certificate.serialNumber);

   

   // Display some information about the distinguished name of signer

   console.println("subjectDN.cn = " + certificate.subjectDN.cn);

   console.println("subjectDN.o = " +  certificate.subjectDN.o);

signatureSetSeedValue

6.0

D 

S 

X 

Sets properties that are used when signing signature fields. The properties are stored in the signature field and are not altered when the field is signed, the signature is cleared, or when resetForm is called. Use signatureGetSeedValue to obtain the property settings.

When setting seed values, keep in mind the following:

Note:The method can be executed during a batch, application initialization or console event. See Privileged versus non-privileged context for details.

Certifying signatures are signatures with a SignatureInfo object mdp property value of allowNone, default, or defaultAndComments.

Not allowed in Adobe Reader.

Refer to the Acrobat 8.0 Security Feature User Reference to obtain a deeper understanding of the use of signature seed values.

Parameters

oSigSeedValue 

A SeedValue object containing the signature seed value properties.

SeedValue Object

A generic JavaScript object, passed to signatureSetSeedValue and returned by signatureGetSeedValue, which represents a signature seed value. It has the following properties:

Property

Type

Access

Description

appearanceFilter

String

R/W

(Acrobat 9.0) A string corresponding to the named appearance that the AppearanceFilter seed value should match.

certspec 

object

R/W

A seed value CertificateSpecifier object. see CertificateSpecifier Object for a listing of the properties of this object.

digestMethod 

Array of strings

R/W

(Acrobat 8) An array of acceptable digest methods to use while signing. The valid string values are SHA1, SHA256, SHA384, SHA512, MD5, and RIPEMD160.

Note:This is only applicable if the DigitalID contains RSA public/private keys. If they contain DSA public/private keys, then the value is always SHA1.

The flags property indicates whether this is a required constraint.

filter 

String

R/W

The language-independent name of the security handler to be used when signing.

If filter is specified and the flags property indicates this entry is a required constraint, then the signature handler specified by this entry must be used when signing; otherwise, signing must not take place. If flags indicates that this is an optional constraint, then this handler should be used if it is available. If it is not available, a different handler can be used instead.

flags 

Number

R/W

A set of bit flags controlling which of the following properties of this object are required. The value is the logical OR of the following values, which are set if the corresponding property is required:

   1: filter
   2: subFilter
   4: version
   8: reasons
  16: legalAttestations
  32: shouldAddRevInfo
  64: digestMethod
 

  128: lockDocument 

  256: appearanceFilter 

Usage: 1 specifies filter, 3 specifies filter and sub-filter, and 11 specifies filter, sub-filter, and reasons. If this field is not present, all properties are optional.

legalAttestations 

Array of Strings

R/W

(Acrobat 7.0) A list of legal attestations that the user can use when creating an Modification Detection and Prevention (MDP) (certified) signature.

The value of the corresponding flag in the flags property indicates whether this is a required or optional constraint.

lockDocument

String

R/W

(Acrobat 9.0) A string corrresponding to one of the three LockDocument seed value states. Values are

   auto
   true
   false
Any other value will not be set.

mdp 

String

R/W

(Acrobat 7.0) The MDP setting to use when signing the field. Values are

  allowNone
  default
  defaultAndComments
 

While allowAll is a legal value, it cancels out the effect of MDP and no certification signature can be used for this field, resulting in the signature being an approval signature, not an certification signature.

Values are unique identifiers and are described in the table titled Modification Detection and Prevention (MDP) Values.

reasons 

Array of Strings

R/W

A list of reasons that the user is allowed to use when signing.

(Acrobat 8.0) If this array has a single element and that element is a single period '.' and if the reasons are marked as required by the flags property, then Acrobat 8 will suppress the UI for specifying a reason during signing. This overrides the users preference.

If this array is empty and reasons are marked as required, an exception will be thrown.

shouldAddRevInfo 

Boolean

R/W

(Acrobat 8) If set to true, instructs the application to carry out revocation checking of the certificate (and the corresponding chains) used to sign, and include all the revocation information within the signature.

Only relevant if subFilter is adbe.pkcs7.detached or adbe.pkcs7.sha1, and it is not applicable for adbe.x509.rsa_sha1. Hence, if the subFilter is adbe.x509.rsa_sha1 and it’s required that revocation information be added, then the signing operation fails.

If shouldAddRevInfo is true and the flags property indicates this is a required constraint, then the tasks described above must be performed. If they cannot be performed, then signing must fail.

The default value is false.

subFilter 

Array of Strings

R/W

An array of acceptable formats to use for the signature. Refer to the Signature Info object’s subFilter property for a list of known formats.

The first name in the array that matches an encoding supported by the signature handler should be the encoding that is actually used for signing. If subFilter is specified and the flags property indicates that this entry is a required constraint, then the first matching encodings must be used when signing; otherwise, signing must not take place. If the flags property indicates that this is an optional constraint, then the first matching encoding should be used if it is available. If it is not available, a different encoding can be used.

timeStampspec 

Object

R/W

(Acrobat 7.0) A Seed Value timeStamp Specifier object. It uses the url and flags properties to specify a timestamp server. See Seed value timeStamp specifier object.

version 

Number

R/W

The minimum required version number of the signature handler to be used to sign the signature field. Valid values are 1 and 2. A value of 1 specifies that the parser must be able to recognize all seed value dictionary entries specified in PDF 1.5. A value of 2 specifies that it must be able to recognize all seed value dictionary entries specified in PDF 1.7 and earlier.

The flags property indicates whether this is a required constraint.

Note:The PDF Reference version 1.6 and earlier, erroneously indicates that the V entry (the key that corresponds to the version parameter) is of type integer. This entry is of type real.

CertificateSpecifier Object

This generic JavaScript object contains the certificate specifier properties of a signature seed value. Used in the certSpec property of the SeedValue object. This object contains the following properties:

Property

Type

Access

Description

flags 

Number

R/W

A set of bit flags controlling which of the following properties of this object are required. The value is the logical OR of the following values, which are set if the corresponding property is required:

  1: subject
  2: issuer
  4: oid
  8: subjectDN
 16: Reserved
 32: keyUsage
 64: url
 

If this field is not present, all properties are optional.

issuer 

Array of Certificate objects

R/W

An array of Certificate objects that are acceptable for signing.

Note:If specified, the signing certificate must be issued by a certificate that is an exact match with one of the certificates in this array.

The value of the corresponding flag in the flags property indicates whether this is a required or optional constraint.

keyUsage 

Object

R/W

(Acrobat 8.0) Array of integers, where each integer specifies the acceptable key-usage extension that must be present in the signing certificate.

Each integer is constructed as follows:

There are two bits used for each key-usage type (defined in RFC 3280) starting from the least significant bit:

digitalSignature(bits 2,1),

nonRepudiation(4,3)

keyEncipherment(6,5)

dataEncipherment(8,7)

keyAgreement(10,9)

keyCertSign(12,11)

cRLSign(14,13)

encipherOnly(16,15)

decipherOnly(18,17)

The value of the two bits have the following semantics:

00: the corresponding keyUsage must not be set

01: the corresponding keyUsage must be set

10 and 11: the state of the corresponding keyUsage doesn’t matter.

For example, if it is required that the key-usage type digitalSignature be set and the state of all other key-usage types do not matter, then the corresponding integer would be 0x7FFFFFFD. That is, to represent digitalSignature, set 01 for bits 2 and 1 respectively, and set 11 for all other key-usage types.

The value of the corresponding flag in the flags property indicates whether this is a required constraint.

oid 

Array of
Strings

R/W

An array of strings that contain Policy OIDs that must be present in the signing certificate. This property is only applicable if the issuer property is present.

The value of the corresponding flag in the flags property indicates whether this is a required or optional constraint.

subject 

Array of Certificate objects

R/W

An array of Certificate objects that are acceptable for signing.

Note:If specified, the signing certificate must be an exact match with one of the certificates in this array.

The value of the corresponding flag in the flags property indicates whether this is a required or optional constraint.

subjectDN 

Array of objects

R/W

(Acrobat 8.0) Array of objects, where each object specifies a Subject Distinguished Name (DN) that is acceptable for signing. A signing certificate satisfies a DN requirement if it at least contains all the attributes specified in the DN (it can therefore contain additional DN attributes). If this entry is specified, the signing certificate must satisfy at least one of the DNs in the array.

DN attribute restrictions are specified in this object by adding them as properties. The properties’ key names can either be the corresponding attributes’ friendly names or OIDs (as defined in RFC 3280). The properties’ value must be of type string.

The value of the corresponding flag in the flags property indicates whether this is a required or optional constraint.

Example 1: {cn:"Alice", ou:"Engineering", o:"Acme Inc"}. The friendly names for the DN attributes (cn, o, ou, and so on) are the ones defined in RDN (see RDN).

Example 2: {cn:"Joe Smith", ou:
"Engineering",
 2.5.4.43:"JS"}, where OID 2.5.4.43 is used to carry out matching for the “Initials” attribute. The following is sample code to define the above DN:

var subjectDN = {cn:"Joe Smith", ou:"Engineering"};
subjectDN["2.4.5.43"] = "JS";
 

Attributes whose value is of type DirectoryString or IA5String can be specified as shown in the example above, whereas for all other value types, for example, dateOfBirth whose value is of type GeneralizedTime, the values need to be specified as a hex-encoded binary string.

For more information about the various attributes and their types, refer to RFC 3280.

url

String

R/W

A URL that can be used to enroll for a new credential if a matching credential is not found.

A degenerate use of this property is when the URL points to a web service that is a DigitalID store (such as a signature web service that can be used for server-based signing). In that case, the URL indicates that as long as the signer has a DigitalID from that web service, it is acceptable for signing.

The value of the corresponding flag in the flags property indicates whether this is a required or optional constraint.

urlType 

String

R/W

(Acrobat 8.0) String indicating the type of URL specified by the url property. These are the valid values for Acrobat 8.0:

"HTML": The URL points to an HTML website and Acrobat will use the web browser to display its contents. The the value of the url bit of the flags property is ignored.

"ASSP": The URL references a signature web service that can be used for server-based signing. If the url bit of the flags property indicates that this is a required constraint, this implies that the credential used when signing must come from this server.

If this attribute isn’t present, it’s assumed that the URL points to a HTML site.

Seed value timeStamp specifier object

The properties of the seed value timeStamp specifier object are as follows:

Property

Type

Access

Description

url 

String

R/W

URL of the timeStamp server providing an RFC 3161 compliant timeStamp.

flags 

Number

R/W

A bit flag controlling whether the time stamp is required (1) or not required (0). The default is 0.

Example 1

Seed the signature field, which has yet to be signed, with MDP, legal attestations, and permitted reasons for signing.

   // Obtain the signature Field object:

   var f = this.getField("mySigField");

   f.signatureSetSeedValue({

      mdp: "defaultAndComments",

      legalAttestations: ["Trust me and be at ease.",

         "You can surely trust the author."],

      reasons: ["This is a reason", "This is a better reason"],

      flags: 8

   })

Example 2

Sets the signing handler as PPKMS and the format as “adbe.pkcs7.sha1”.

   var f = this.getField( "mySigField" );

   

   f.signatureSetSeedValue({

      filter: "Adobe.PPKMS",

      subFilter: ["adbe.pkcs7.sha1"],

      flags: 3

});

Example 3

Sets the signing handler as PPKLite and the issuer of the signer’s certificate as caCert. Both are mandatory seed values and signing will fail if either constraint is not met.

   var caCert = security.importFromFile("Certificate", "/C/temp/CA.cer");

   f.signatureSetSeedValue({

      filter: "Adobe.PPKLite",

      certspec: {

         issuer: [caCert],

         url: "http://www.example.com/enroll.html",

         flags : 2

      },

      flags: 1

   });

signatureSign

5.0

D 

S 

G 

Signs the field with the specified security handler. See also security.getHandler and securityHandler.login.

Note:This method can only be executed during a batch, console, or application initialization event. See Privileged versus non-privileged context for details. The event object contains a discussion of JavaScript events.

Signature fields cannot be signed if they are already signed. Use resetForm to clear signature fields.

Parameters

oSig 

Specifies the SecurityHandler object to be used for signing. Throws an exception if the specified handler does not support signing operations. Some security handlers require that the user be logged in before signing can occur. If oSig is not specified, this method selects a handler based on user preferences or by prompting the user if bUI is true.

oInfo 

(optional) A SignatureInfo object specifying the writable properties of the signature. See also signatureInfo.

cDIPath 

(optional) The device-independent path to the file to save to following the application of the signature. If not specified, the file is saved back to its original location.

bUI 

(optional, Acrobat 6.0) A Boolean value specifying whether the security handler should show the user interface when signing. If true, oInfo and cDIPath are used as default values in the signing dialog boxes. If false (the default), the signing occurs without a user interface.

cLegalAttest 

(optional, Acrobat 6.0) A string that can be provided when creating an certification signature.

Certification signatures are signatures where the mdp property of the SignatureInfo object has a value other than allowAll. When creating an certification signature, the document is scanned for legal warnings and these warnings are embedded in the document. A caller can determine what legal warnings are found by first calling the Doc getLegalWarnings method. If warnings are to be embedded, an author may provide an attestation as to why these warnings are being applied to a document.

Returns

true if the signature was applied successfully, false otherwise.

Example 1

Sign the “Signature” field with the PPKLite signature handler:

   var myEngine = security.getHandler( "Adobe.PPKLite" );

   myEngine.login( "dps017", "/c/profile/dps.pfx" );

   var f = this.getField("Signature");

   

   // Sign the field

   f.signatureSign( myEngine,

      {   password: "dps017",             // provide password

         location: "San Jose, CA",       // ... see note below

         reason: "I am approving this document",

         contactInfo: "dpsmith@example.com",

         appearance: "Fancy"});

Note:In the above example, a password was provided. This may or may not have been necessary depending whether the Password Timeout had expired. The Password Timeout can be set programmatically by securityHandler.setPasswordTimeout.

Example 2

Sign an certification signature field.

   var myEngine = security.getHandler( "Adobe.PPKLite" );

   myEngine.login( "dps017", "/c/profile/dps.pfx" );

   

   var f = this.getField( "AuthorSigFieldName" );

   var s = { reason: "I am the author of this document",

         mdp: "allowNone" };

   f.signatureSign({

      oSig: myEngine,

      oInfo: s,

      bUI: false,

      cLegalAttest: "To reduce file size, fonts are not embedded."

   });

signatureValidate

5.0

 

 

 

Validates and returns the validity status of the signature in a signature field. This routine can be computationally expensive and take a significant amount of time depending on the signature handler used to sign the signature.

Note:There are no restrictions on when this method can be called. However, the parameter oSig is not always available. See security.getHandler for details.

Parameters

oSig 

(optional) The security handler to be used to validate the signature. Its value is either a SecurityHandler object or a SignatureParameters object. If this handler is not specified, the method uses the security handler returned by the signature’s handlerName property.

bUI 

(optional, Acrobat 6.0) If true, allows the UI to be shown when validating, if necessary. The UI may be used to select a validation handler if none is specified. The default is false.

Returns

The validity status of the signature. Validity values are:

-1 — Not a signature field

0 — Signature is blank

1 — Unknown status

2 — Signature is invalid

3 — Signature of document is valid, identity of signer could not be verified

4 — Signature of document is valid and identity of signer is valid.

See the signVisible and statusText properties of the SignatureInfo object.

SignatureParameters object

A generic object with the following properties that specify which security handlers are to be used for validation by signatureValidate:

oSecHdlr 

The security handler object to use to validate this signature.

bAltSecHdlr 

If true, an alternate security handler, selected based on user preference settings, may be used to validate the signature. The default is false, which means that the security handler returned by the signature’s handlerName property is used to validate the signature. This parameter is not used if oSecHdlr is provided.

Example

Validate a signature, then report to the console.

   var f = this.getField("Signature1") // Get signature field

   var status = f.signatureValidate();

   var sigInfo = f.signatureInfo();

   if ( status < 3 )

       var msg = "Signature not valid! " + sigInfo.statusText;

   else

      var msg = "Signature valid! " + sigInfo.statusText;

   app.alert(msg);