4.3.  Comparing Actions

Quantity

The first example shows how to compare the number of actions of two PDF documents:

<testcase name="haveSameNumberOfActions">
  <assertThat testDocument="test/test.pdf"
              masterDocument="master/master.pdf"
  >
    <haveSameNumberOfActions />
  </assertThat>
</testcase>

Properties

To compare all actions of two PDF documents, you can use the tag <haveSameActions />:

<testcase name="haveSameActions">
  <assertThat testDocument="test/test.pdf"
              masterDocument="master/master.pdf"
  >
    <haveSameActions />
  </assertThat>
</testcase>

The decision whether two actions are equal depends on their type. The following table shows the properties for each type of action which determine whether the actions are equal:

Type Relevant Property for equals()
GotoAction
destination The destination the action is pointing to.
orientation The orientation of the destination, for example /FIT.
GotoEmbeddedAction
destination The destination the action is pointing to.
new window Whether the destination is shown in a separate window.
GotoRemoteAction
filename The file the action wants to go to.
page number The page in the remote file.
remote destination A destination inside the remote file.
new window Whether the destination is shown in a separate window.
ImportDataAction
filename The file the action wants to import.
JavaScriptAction
javaScript The JavaScript code. Whitespaces are reduced as described in chapter 13.4: “Whitespace Processing”.
LaunchAction
filename The file the action wants to launch.
default directory The directory of the file.
operation The operation for the filename, for example print.
parameters Parameters passed to the application.
NamedAction
name The name of the action.
ResetFormAction
fields The names of the field which will be reset.
flags Settings specifying characteristics of the field.
SubmitFormAction
destination The destination the field information will be sent to.
fields The fields whose values will be transmitted.
flags Settings defining the data transfer mechanism. For example PdfAction.SUBMIT_HTML_GET or PdfAction.SUBMIT_PDF.
URIAction
destination Where the action is pointing to.

The following events are always related to JavaScript actions:

  • document close (/DC)

  • document will print (/WP)

  • document did print (/DP)

  • document will save (/WS)

  • document did save (/DS)

The event document open (/DocumentOpen) can be linked to any action in the list. The equality of two document open actions depends on their actual type.