# PDF Action API Migration Guide
This chapter focuses on the migration of PDF Action related APIs from the previou version to the new version, aiming to assist developers in upgrading their code smoothly.
# Changes in Action Retrieval and Manipulation APIs
# Previous Version
// Get Additional Action object
Widget#getAdditionalAction(type)
// Get Action object
Widget#getAction();
// Remove Additional Action object from a Link
Link#removeAction(trigger, action);
// Remove Additional Action object from a Screen
Screen#removeAction(trigger, action);
# New Version
// Note: Here, Annot 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 the AdditionalAction object
const additionalAction = await Annot#getAdditionalAction();
// Remove an Additional Action based on trigger type and Action object number
await additionalAction.removeAction(trigger, targetActionObjNumber);
// Add a new Action
await additionalAction.addAction(trigger, actionSpec);
// Update the information of a specific Action
await additionalAction.updateActionData(trigger, targetActionObjNumber, actionData);
// Override all Action for a specific trigger type
await additionalAction.setAction(trigger, actionSpec);
# Key Changes Description
In the previous version, Action was accessed using
Widget#getAction
andWidget#getAdditionalAction(type)
methods.In the new version, Action is managed uniformly through asynchronous methods of the
Annot
object, which includes Widget, Screen, Link, and Sound.The new version adds more granular capabilities for handling Action, such as batch retrieval, updates, and deletions.
For operations related to AdditionalAction, the new version requires first obtaining the AdditionalAction object via the
Annot#getAdditionalAction()
method, followed by performing actions such as adding, removing, updating, and querying.
# ActionCallbackManager.setEmbeddedGotoCallback - Callback Parameter Changes
# Previous Version
In the previous version, the callback parameter was an EmbeddedGotoAction
(opens new window) object:
const actionCallbackManager = actionpdfviewer.getActionCallbackManager();
actionCallbackManager.setEmbeddedGotoCallback(async (action) => {
console.log(action.getDestination());
});
# New Version
In the new version, the callback parameter is an ExecuteActionOptions
(opens new window) object:
const actionCallbackManager = actionpdfviewer.getActionCallbackManager();
actionCallbackManager.setEmbeddedGotoCallback(async (options) => {
console.log(
options.data,
options.doc,
options.ownerQuery,
options.pdfViewer,
options.trigger
);
});
# Major Changes Description
- The callback parameter in the new version is more comprehensive, including action data, document objects, and trigger sources, making it easier for developers to implement more complex business logic.
- For specific fields, please refer to the API Documentation (opens new window).
For more detailed information, please refer to the API Reference Documentation (opens new window).