# Class: Action

## PDFNet. Action

#### new Action()

  Actions are typically what happens when a user clicks on a link or bookmark.

  Instead of simply jumping to a destination in the document, an annotation or outline item can specify an action for the viewer application to perform, such as launching an application, playing a sound, or changing an annotation's appearance state.

### Methods

#### <static> create(in_obj)

  A constructor. Creates an Action and initializes it using given Cos/SDF object.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `in_obj` | PDFNet.Obj | Pointer to the Cos/SDF object.

  ##### Returns:

  A promise that resolves to an object of type: "Action"

  Type
    PDFNet.Action

#### <static> createGoto(dest)

  creates a new 'GoTo'action. GoTo action takes the user to the specified Destination view located in the same document.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `dest` | PDFNet.Destination | A Destination for the new Action.

  ##### Returns:

  A promise that resolves to an object of type: "Action"

  Type
    PDFNet.Action

#### <static> createGotoRemote(file, page_num)

  creates a new 'GoToR'action. A remote go-to action is similar to an ordinary go-to action but jumps to a destination in another PDF file instead of the current file.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `file` | PDFNet.FileSpec | The file referred to by the action.
  `page_num` | number | A page number within the remote document. The first page is numbered 0.

  ##### Returns:

  A promise that resolves to an object of type: "Action"

  Type
    PDFNet.Action

#### <static> createGotoRemoteSetNewWindow(file, page_num, new_window)

  Creates a new 'GoToR'action. See the above method for details.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `file` | PDFNet.FileSpec | The file referred to by the action.
  `page_num` | number | A page number within the remote document. The first page is numbered 0.
  `new_window` | boolean | A flag specifying whether to open the destination document in a new window. If new_window is false, the destination document replaces the current document in the same window, otherwise the viewer application should behave in accordance with the current user preference.

  ##### Returns:

  A promise that resolves to an object of type: "Action"

  Type
    PDFNet.Action

#### <static> createGotoWithKey(key, dest)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `key` | string |
  `dest` | PDFNet.Destination |

  ##### Returns:

  A promise that resolves to an object of type: "Action"

  Type
    PDFNet.Action

#### <static> createHideField(sdfdoc, list_length, field_list)

  Creates a new 'Show/Hide Field' action. A show/hide field action shows or hide certain fields when it's invoked.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `sdfdoc` | PDFNet.SDFDoc | the document in which to create the action
  `list_length` | number | the number of fields to hide
  `field_list` | string | the list of fields to hide

  ##### Returns:

  A promise that resolves to an object of type: "Action"

  Type
    PDFNet.Action

#### <static> createImportData(sdfdoc, path)

  Creates a new 'Import Data' action. An import data action imports form data from a FDF file into a PDF document.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `sdfdoc` | PDFNet.SDFDoc | the document in which to create the action
  `path` | string | the full path of the FDF file

  ##### Returns:

  A promise that resolves to an object of type: "Action"

  Type
    PDFNet.Action

#### <static> createJavaScript(sdfdoc, script)

  Creates a new 'JavaScript' action. A javascript action executes a JavaScript script when it's invoked.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `sdfdoc` | PDFNet.SDFDoc | the document in which to create the action
  `script` | string | the JavaScript script to be executed

  ##### Returns:

  A promise that resolves to an object of type: "Action"

  Type
    PDFNet.Action

#### <static> createLaunch(sdfdoc, path)

  Creates a new 'Launch' action. A launch action opens up a file using the most appropriate program.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `sdfdoc` | PDFNet.SDFDoc | the document in which to create the action
  `path` | string | the full path of the file to be opened

  ##### Returns:

  A promise that resolves to an object of type: "Action"

  Type
    PDFNet.Action

#### <static> createResetForm(sdfdoc)

  Creates a new 'Reset Form' action. A reset form action reset chosen form fields to their default value.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `sdfdoc` | PDFNet.SDFDoc | the document in which to create the action

  ##### Returns:

  A promise that resolves to an object of type: "Action"

  Type
    PDFNet.Action

#### <static> createSubmitForm(url)

  creates a new 'SubmitForm'action. A submit-form action transmits the names and values of selected interactive form fields to a specified uniform resource locator (URL), presumably the address of a Web server that will process them and send back a response.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `url` | PDFNet.FileSpec | A URL file specification giving the uniform resource locator (URL) of the script at the Web server that will process the submission.

  ##### Returns:

  A promise that resolves to an object of type: "Action"

  Type
    PDFNet.Action

#### <static> createURI(sdfdoc, uri)

  Create a new URI action. The URI action is typically resolved by opening a URL in the default web browser.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `sdfdoc` | PDFNet.SDFDoc | The document in which to create the action.
  `uri` | string | The uniform resource identifier to resolve, encoded in 7-bit ASCII. A uniform resource identifier (URI) is a string that identifies (resolves to) a resource on the Internet; typically a file that is the destination of a hypertext link, although it can also resolve to a query or other entity. (URIs are described in Internet RFC 2396, Uniform Resource Identifiers (URI).

  ##### Returns:

  A promise that resolves to an object of type: "Action"

  Type
    PDFNet.Action

#### <static> createURIWithUString(sdfdoc, current)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `sdfdoc` | PDFNet.SDFDoc |
  `current` | string |

  ##### Returns:

  A promise that resolves to an object of type: "Action"

  Type
    PDFNet.Action

#### compare(in_action)

  Compares two Action objects for equality.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `in_action` | PDFNet.Action | A reference to an existing Action object.

  ##### Returns:

  A promise that resolves to true if the both Actions share the same underlying SDF/Cos object; otherwise false.

  Type
    boolean

#### copy()

  ##### Returns:

  A promise that resolves to an object of type: "Action"

  Type
    PDFNet.Action

#### execute()

  Executes current action; this will only work for some action types that can be executed only using the information contained in the action object or the associated PDF doc. See also PDFViewCtrl::ExecuteAction()

#### executeKeyStrokeAction(data)

  Executes KeyStrokeAction, this shall be performed when the user modifies a character in a text field or combo box or modifies the selecton in a scrollable list box. This action checks the added text for validity and reject or modify it.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `data` | PDFNet.KeyStrokeEventData | Data that contains previous text, added text,and added position information.

  ##### Returns:

  A promise that resolves to an object of type: "KeyStrokeActionResult"

  Type
    PDFNet.KeyStrokeActionResult

#### getDest()

  ##### Returns:

  A promise that resolves to the Action's Destination view.

  Type
    PDFNet.Destination

#### getFormActionFlag(flag)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `flag` | number/enum |
      PDFNet.Action.FormActionFlag = {
      	e_exclude : 0
      	e_include_no_value_fields : 1
      	e_export_format : 2
      	e_get_method : 3
      	e_submit_coordinates : 4
      	e_xfdf : 5
      	e_include_append_saves : 6
      	e_include_annotations : 7
      	e_submit_pdf : 8
      	e_canonical_format : 9
      	e_excl_non_user_annots : 10
      	e_excl_F_key : 11
      	e_embed_form : 13
      }
  Action flag to get the value from.

  ##### Returns:

  A promise that resolves to boolean value of the given action flag.

  Type
    boolean

#### getNext()

  ##### Returns:

  A promise that resolves to the next action dictionary, an array of action dictionaries, or NULL if there are no additional actions.

  Sequences of actions can be chained together. For example, the effect of clicking a link annotation with the mouse might be to play a sound, jump to a new page, and start up a movie. Note that the Next entry is not restricted to a single action but may contain an array of actions, each of which in turn may have a Next entry of its own. The actions may thus form a tree instead of a simple linked list. Actions within each Next array are executed in order, each followed in turn by any actions specified in its Next entry, and so on recursively.

  Type
    PDFNet.Obj

#### getSDFObj()

  ##### Returns:

  A promise that resolves to pointer to the underlying SDF/Cos object.

  Type
    PDFNet.Obj

#### getType()

  ##### Returns:

  A promise that resolves to the type of this Action.

  Type
    number

  ##### Example

      Return value enum:
      <pre>
      PDFNet.Action.Type = {
      	e_GoTo : 0
      	e_GoToR : 1
      	e_GoToE : 2
      	e_Launch : 3
      	e_Thread : 4
      	e_URI : 5
      	e_Sound : 6
      	e_Movie : 7
      	e_Hide : 8
      	e_Named : 9
      	e_SubmitForm : 10
      	e_ResetForm : 11
      	e_ImportData : 12
      	e_JavaScript : 13
      	e_SetOCGState : 14
      	e_Rendition : 15
      	e_Trans : 16
      	e_GoTo3DView : 17
      	e_RichMediaExecute : 18
      	e_Unknown : 19
      }
      </pre>

#### isValid()

  Indicates whether the Action is valid (non-null).

  ##### Returns:

  A promise that resolves to true if this is a valid (non-null) Action; otherwise false.

  Type
    boolean

#### needsWriteLock()

  Test if the action needs writeLock

  ##### Returns:

  A promise that resolves to ture if needs, otherwise false

  Type
    boolean

#### setFormActionFlag(flag, value)

  Set the value of a given field flag.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `flag` | number/enum |
      PDFNet.Action.FormActionFlag = {
      	e_exclude : 0
      	e_include_no_value_fields : 1
      	e_export_format : 2
      	e_get_method : 3
      	e_submit_coordinates : 4
      	e_xfdf : 5
      	e_include_append_saves : 6
      	e_include_annotations : 7
      	e_submit_pdf : 8
      	e_canonical_format : 9
      	e_excl_non_user_annots : 10
      	e_excl_F_key : 11
      	e_embed_form : 13
      }
  Action flag to get the value from.
  `value` | boolean | Boolean to set the value of the flag to. Action flags are currently only used by submit and reset form actions.

#### Search results