Summary: Constants | Ctors | Methods | Inherited Methods | [Expand All]
public class

# Action

extends Object

java.lang.Object
↳ | com.pdftron.pdf.Action

## Class Overview

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.

Note: Although the Action class provides utility functions for most commonly used action types, it is possible to read, write, and edit any action type using SDF API and dictionary entries described in Section 8.5 in the PDF Reference Manual.

## Summary

Constants
int | e_GoTo | PDF supports the standard action types listed in the following table.
int | e_GoTo3DView | The Constant e_GoTo3DView.
int | e_GoToE | The Constant e_GoToE.
int | e_GoToR | The Constant e_GoToR.
int | e_Hide | The Constant e_Hide.
int | e_ImportData | The Constant e_ImportData.
int | e_JavaScript | The Constant e_JavaScript.
int | e_Launch | The Constant e_Launch.
int | e_Movie | The Constant e_Movie.
int | e_Named | The Constant e_Named.
int | e_Rendition | The Constant e_Rendition.
int | e_ResetForm | The Constant e_ResetForm.
int | e_SetOCGState | The Constant e_SetOCGState.
int | e_Sound | The Constant e_Sound.
int | e_SubmitForm | The Constant e_SubmitForm.
int | e_Thread | The Constant e_Thread.
int | e_Trans | The Constant e_Trans.
int | e_URI | The Constant e_URI.
int | e_Unknown | The Constant e_Unknown.
int | e_canonical_format | The Constant e_canonical_format.
int | e_embed_form | The Constant e_embed_form.
int | e_excl_F_key | The Constant e_excl_F_key.
int | e_excl_non_user_annots | The Constant e_excl_non_user_annots.
int | e_exclude | Flags used by submit form actions.
int | e_export_format | The Constant e_export_format.
int | e_get_method | The Constant e_get_method.
int | e_include_annotations | The Constant e_include_annotations.
int | e_include_append_saves | The Constant e_include_append_saves.
int | e_include_no_value_fields | The Constant e_include_no_value_fields.
int | e_submit_coordinates | The Constant e_submit_coordinates.
int | e_submit_pdf | The Constant e_submit_pdf.
int | e_xfdf | The Constant e_xfdf.

Public Constructors
| Action(Obj in_obj) A constructor.

Public Methods
void | 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.
Obj | GetNext() Get the next action dictionary or dictionaries in an array.
static Action | __Create(long impl, Object ref)
long | __GetHandle()
Object | __GetRefHandle()
static Action | createGoto(byte[] key, Destination dest) Creates a new 'GoTo' action using a 'Named Destination'.
static Action | createGoto(Destination dest) Creates a new 'GoTo'action.
static Action | createGotoRemote(FileSpec file, int page_num) Creates a new 'GoToR' action.
static Action | createGotoRemote(FileSpec file, int page_num, boolean new_window) Creates a new 'GoToR' action.
static Action | createHideField(PDFDoc doc, String[] field_list) Creates a new 'Show/Hide Field' action.
static Action | createImportData(PDFDoc doc, String path) Creates a new 'Import Data' action.
static Action | createJavaScript(PDFDoc doc, String script) Creates a new 'JavaScript' action.
static Action | createLaunch(PDFDoc doc, String path) Creates a new 'Launch' action.
static Action | createResetForm(PDFDoc doc) Creates a new 'Reset Form' action.
static Action | createSubmitForm(FileSpec url) Creates a new 'SubmitForm' action.
static Action | createURI(PDFDoc doc, String uri) Create a new URI action.
boolean | equals(Object in_action) Compares two Action objects for equality.
KeyStrokeActionResult | executeKeyStrokeAction(KeyStrokeEventData 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.
Destination | getDest() Get the destination view of the Action Note: This only applies for Actions whose subtype is "GoTo".
int | getFormActionFlag(int flag) Get the form action flag.
Obj | getSDFObj() Get the SDFObj.
int | getType() Get the action type.
int | hashCode()
boolean | isValid() Indicates whether the Action is valid (non-null).
boolean | needsWriteLock() Test whether this action needs WriteLock
void | setFormActionFlag(int flag, boolean value) Set the value of a given field flag.

[Expand] Inherited Methods
From class java.lang.Object
boolean | equals(Object arg0)
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()

## Constants

#### public static final int e_GoTo

PDF supports the standard action types listed in the following table. Plug-in extensions may add new action types.

Constant Value: 0 (0x00000000)

#### public static final int e_GoTo3DView

The Constant e_GoTo3DView.

Constant Value: 17 (0x00000011)

#### public static final int e_GoToE

The Constant e_GoToE.

Constant Value: 2 (0x00000002)

#### public static final int e_GoToR

The Constant e_GoToR.

Constant Value: 1 (0x00000001)

#### public static final int e_Hide

The Constant e_Hide.

Constant Value: 8 (0x00000008)

#### public static final int e_ImportData

The Constant e_ImportData.

Constant Value: 12 (0x0000000c)

#### public static final int e_JavaScript

The Constant e_JavaScript.

Constant Value: 13 (0x0000000d)

#### public static final int e_Launch

The Constant e_Launch.

Constant Value: 3 (0x00000003)

#### public static final int e_Movie

The Constant e_Movie.

Constant Value: 7 (0x00000007)

#### public static final int e_Named

The Constant e_Named.

Constant Value: 9 (0x00000009)

#### public static final int e_Rendition

The Constant e_Rendition.

Constant Value: 15 (0x0000000f)

#### public static final int e_ResetForm

The Constant e_ResetForm.

Constant Value: 11 (0x0000000b)

#### public static final int e_SetOCGState

The Constant e_SetOCGState.

Constant Value: 14 (0x0000000e)

#### public static final int e_Sound

The Constant e_Sound.

Constant Value: 6 (0x00000006)

#### public static final int e_SubmitForm

The Constant e_SubmitForm.

Constant Value: 10 (0x0000000a)

#### public static final int e_Thread

The Constant e_Thread.

Constant Value: 4 (0x00000004)

#### public static final int e_Trans

The Constant e_Trans.

Constant Value: 16 (0x00000010)

#### public static final int e_URI

The Constant e_URI.

Constant Value: 5 (0x00000005)

#### public static final int e_Unknown

The Constant e_Unknown.

Constant Value: 18 (0x00000012)

#### public static final int e_canonical_format

The Constant e_canonical_format.

Constant Value: 9 (0x00000009)

#### public static final int e_embed_form

The Constant e_embed_form.

Constant Value: 13 (0x0000000d)

#### public static final int e_excl_F_key

The Constant e_excl_F_key.

Constant Value: 11 (0x0000000b)

#### public static final int e_excl_non_user_annots

The Constant e_excl_non_user_annots.

Constant Value: 10 (0x0000000a)

#### public static final int e_exclude

Flags used by submit form actions. Exclude flag is also used by reset form action. No other action types use flags in the current version of PDF standard (ISO 2300).

Constant Value: 0 (0x00000000)

#### public static final int e_export_format

The Constant e_export_format.

Constant Value: 2 (0x00000002)

#### public static final int e_get_method

The Constant e_get_method.

Constant Value: 3 (0x00000003)

#### public static final int e_include_annotations

The Constant e_include_annotations.

Constant Value: 7 (0x00000007)

#### public static final int e_include_append_saves

The Constant e_include_append_saves.

Constant Value: 6 (0x00000006)

#### public static final int e_include_no_value_fields

The Constant e_include_no_value_fields.

Constant Value: 1 (0x00000001)

#### public static final int e_submit_coordinates

The Constant e_submit_coordinates.

Constant Value: 4 (0x00000004)

#### public static final int e_submit_pdf

The Constant e_submit_pdf.

Constant Value: 8 (0x00000008)

#### public static final int e_xfdf

The Constant e_xfdf.

Constant Value: 5 (0x00000005)

## Public Constructors

#### public Action (Obj in_obj)

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

Note: The constructor does not copy any data, but is instead the logical equivalent of a type cast.

##### Parameters

in_obj | Pointer to the Cos/SDF object.

##### Throws

PDFNetException |

## Public Methods

#### public void 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()

##### Throws

PDFNetException |

#### public Obj GetNext ()

Get the next action dictionary or dictionaries in an array.

##### Returns

- 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.

##### Throws

PDFNetException |

#### public static Action __Create (long impl, Object ref)

#### public long __GetHandle ()

#### public Object __GetRefHandle ()

#### public static Action createGoto (byte[] key, Destination dest)

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

##### Parameters

key | - a string buffer representing the destination name. The named destination will be stored in document's '/Dest' SDF::NameTree.
dest | The explicit destination used to create the named destination.

##### Returns

- the created 'GoTo' action

##### Throws

PDFNetException |

#### public static Action createGoto (Destination dest)

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

Note: This method can only be used for destinations in the same document as the source document. For cross-document links use Action::CreateGotoRemote().

##### Parameters

dest | A Destination for the new Action.

##### Returns

- the created 'GoTo' action

##### Throws

PDFNetException |

#### public static Action createGotoRemote (FileSpec file, int 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

file | The file referred to by the action.
page_num | A page number within the remote document. The first page is numbered 0.

##### Returns

- the created 'GoToR' action

##### Throws

PDFNetException |

#### public static Action createGotoRemote (FileSpec file, int page_num, boolean new_window)

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

##### Parameters

file | The file referred to by the action.
page_num | A page number within the remote document. The first page is numbered 0.
new_window | 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

- the created 'GoToR' action

##### Throws

PDFNetException |

#### public static Action createHideField (PDFDoc doc, String[] field_list)

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

##### Parameters

doc | the document in which to create the action
field_list | field the list of fields to hide

##### Returns

- the created 'Show/Hide Field' action

#### public static Action createImportData (PDFDoc doc, String path)

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

##### Parameters

doc | the document in which to create the action
path | the full path of the FDF file

##### Returns

- the created 'Import Data' action

#### public static Action createJavaScript (PDFDoc doc, String script)

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

##### Parameters

doc | the document in which to create the action
script | the JavaScript script to be executed

##### Returns

- the created 'JavaScript' action

#### public static Action createLaunch (PDFDoc doc, String path)

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

##### Parameters

doc | the document in which to create the action
path | the full path of the file to be opened

##### Returns

- the created 'Launch' action

#### public static Action createResetForm (PDFDoc doc)

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

##### Parameters

doc | the document in which to create the action

##### Returns

- the created 'Reset Form' action

#### public static Action createSubmitForm (FileSpec 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

url | A URL file specification giving the uniform resource locator (URL) of the script at the Web server that will process the submission.

##### Returns

- the created 'SubmitForm' action

##### Throws

PDFNetException |

#### public static Action createURI (PDFDoc doc, String uri)

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

##### Parameters

doc | The document in which to create the action.
uri | 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

- the created URI action

##### Throws

PDFNetException |

#### public boolean equals (Object in_action)

Compares two Action objects for equality.

##### Parameters

in_action | A reference to an existing Action object.

##### Returns

- True if the both Actions share the same underlying SDF/Cos object; otherwise false.

#### public KeyStrokeActionResult executeKeyStrokeAction (KeyStrokeEventData 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

data | Data that contains previous text, added text,and added position information.

##### Throws

PDFNetException |

#### public Destination getDest ()

Get the destination view of the Action

Note: This only applies for Actions whose subtype is "GoTo".

Note: All named destinations are automatically resolved to the explicit destination so you can access destination members directly.

##### Returns

- The Action's Destination view.

##### Throws

PDFNetException |

#### public int getFormActionFlag (int flag)

Get the form action flag.

Note: Action flags are currently only used by submit and reset form actions.

##### Parameters

flag | the flag

##### Returns

- value of the given action flag.

##### Throws

PDFNetException |

#### public Obj getSDFObj ()

Get the SDFObj.

##### Returns

- Pointer to the underlying SDF/Cos object.

#### public int getType ()

Get the action type.

##### Returns

- The type of this Action.

##### Throws

PDFNetException |

#### public int hashCode ()

#### public boolean isValid ()

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

Note: If this method returns false the underlying SDF/Cos object is null and the Action object should be treated as null as well.

##### Returns

- True if this is a valid (non-null) Action; otherwise false.

##### Throws

PDFNetException |

#### public boolean needsWriteLock ()

Test whether this action needs WriteLock

##### Returns

- true if it needs, otherwise return false

##### Throws

PDFNetException |

#### public void setFormActionFlag (int flag, boolean value)

Set the value of a given field flag. Action flags are currently only used by submit and reset form actions.

##### Parameters

flag | given field flag
value | value of the flag

##### Throws

PDFNetException |