Skip to content

PDF Action API Migration Guide ​

This section describes how to migrate PDF Action APIs from older versions to the current release so you can upgrade your code smoothly.

Action retrieval and operation API changes ​

Previous version ​

javascript
// Get Additional Action object
Widget
#getAdditionalAction(type)
// Get Action object
Widget
#getAction();
// Remove Additional Action on Link
Link
#removeAction(trigger, action);
// Remove Additional Action on Screen
Screen
#removeAction(trigger, action);

Current version ​

javascript
// Note: Annot here refers to Widget, Screen, Link, and Sound
// Get Action information
await Annot
#getActionData();
// Get all Action information (including Additional Action and regular Action)
await Annot
#getAllActionData();

// Update a specific Action
await Annot
#updateAction(targetActionObjNumber, actionData);
// Remove a specific Action
await Annot
#removeAction(targetActionObjNumber);

// Get AdditionalAction object
const additionalAction = await Annot
#getAdditionalAction();

// Remove Additional Action by trigger type and Action object number
await additionalAction.removeAction(trigger, targetActionObjNumber);
// Add a new Action
await additionalAction.addAction(trigger, actionSpec);
// Update Action information
await additionalAction.updateActionData(trigger, targetActionObjNumber, actionData);
// Replace all Actions for a trigger type
await additionalAction.setAction(trigger, actionSpec);

Summary of changes ​

  • The previous version used Widget#getAction and Widget#getAdditionalAction(type) to obtain Actions.

  • The current version uses asynchronous methods on Annot (Widget, Screen, Link, Sound) to get and manage Actions.

  • Batch get, update, and remove operations provide finer-grained control.

  • For AdditionalAction, call Annot#getAdditionalAction() first, then add, remove, update, or query Actions on that object.

ActionCallbackManager.setEmbeddedGotoCallback callback parameter change ​

Previous version ​

The callback received an EmbeddedGotoAction object:

javascript
const actionCallbackManager = actionpdfviewer.getActionCallbackManager();
actionCallbackManager.setEmbeddedGotoCallback(async (action) => {
    console.log(action.getDestination());
});

Current version ​

The callback receives an ExecuteActionOptions object:

javascript
const actionCallbackManager = actionpdfviewer.getActionCallbackManager();
actionCallbackManager.setEmbeddedGotoCallback(async (options) => {
    console.log(
        options.data,
        options.doc,
        options.ownerQuery,
        options.pdfViewer,
        options.trigger
    );
});

Summary of changes ​

  • The new callback provides richer context: action data, document object, trigger source, and more for complex integrations.
  • See the API documentation for field details.