FoxitPDFSDKforWeb  v9.2.1
Foxit PDF SDK for Web
UndoRedoAddon Class Reference

Provides undo and redo functionality for document operations within the UIExtension. More...

Inherits UIXAddon.

Public Member Functions

 invoke (callback)
 Executes a callback function to add document operation history to the undo stack. More...
 
 redo ()
 Redoes the previously undone document operation. More...
 
 undo ()
 Undoes the last document operation. More...
 
 undoAll ()
 Undoes the all document operations. More...
 

Detailed Description

Provides undo and redo functionality for document operations within the UIExtension.

This addon allows users to undo and redo document operations, making it easy to navigate through changes made to the PDF document.

Since
9.2.0
Example of obtaining and using the UndoRedo Addon:
pdfui.getAddonInstance('UndoRedoAddon').then(undoRedoAddon => {
if (undoRedoAddon) {
undoRedoAddon.undo();
} else {
console.error("UndoRedo Addon instance not found.");
}
});

Member Function Documentation

◆ invoke()

UndoRedoAddon::invoke (   callback)
inline

Executes a callback function to add document operation history to the undo stack.

Use this method to execute a callback function that performs document operations, such as creating, deleting, or modifying annotations. The operation history of these actions will be automatically added to the undo stack, enabling users to undo these actions if needed. If no document is currently open, the pdfDoc parameter within the callback function will be null.

Parameters
callback(pdfDoc:PDFDoc)=>void - A callback function that receives a pdfDoc parameter and should perform the document operation to be added to the undo stack.
Returns
void -
Since
9.2.0
Example of using this API:
pdfui.getAddonInstance('UndoRedoAddon').then(undoRedoAddon => {
if (undoRedoAddon) {
undoRedoAddon.invoke(async pdfDoc => {
const pdfPage = await pdfDoc.getPageByIndex(0);
pdfPage.addAnnot({...}); // Perform document operation to be added to the undo stack.
});
} else {
console.error("UndoRedo Addon instance not found.");
}
});

◆ redo()

UndoRedoAddon::redo ( )
inline

Redoes the previously undone document operation.

Returns
Promise<void> - A Promise that resolves when the redo operation is completed.
Since
9.2.0
Example of redoing the previously undone document operation:
pdfui.getAddonInstance('UndoRedoAddon').then(undoRedoAddon => {
if (undoRedoAddon) {
undoRedoAddon.redo();
} else {
console.error("UndoRedo Addon instance not found.");
}
});

◆ undo()

UndoRedoAddon::undo ( )
inline

Undoes the last document operation.

Returns
Promise<void> - A Promise that resolves when the undo operation is completed.
Since
9.2.0
Example of undoing the last document operation:
pdfui.getAddonInstance('UndoRedoAddon').then(undoRedoAddon => {
if (undoRedoAddon) {
undoRedoAddon.undo();
} else {
console.error("UndoRedo Addon instance not found.");
}
});

◆ undoAll()

UndoRedoAddon::undoAll ( )
inline

Undoes the all document operations.

Returns
Promise<void> - A Promise that resolves when the undo operation is completed.
Since
9.2.0
Example of undoing all document operations:
pdfui.getAddonInstance('UndoRedoAddon').then(undoRedoAddon => {
if (undoRedoAddon) {
undoRedoAddon.undoAll();
} else {
console.error("UndoRedo Addon instance not found.");
}
});

Foxit Software Corporation Logo
@2023 Foxit Software Incorporated. All rights reserved.