Skip to content
Guides

Undo and Redo

The CPDFEditManager class of CPDFReaderView provides undo and redo functionalities.

Undo refers to reversing previous actions and restoring the document to its previous state. After a user operates, if they find the result unsatisfactory, they can undo the step to revert to the previous state. This helps prevent data or progress loss due to mistakes or dissatisfaction with the outcome.

Redo is a complementary feature to undo; it allows users to reapply previously undone actions, restoring the system state to its state before the undo. Redo is typically used when a user realizes that the initially undone actions were necessary after one or multiple undo steps.

This example shows how to undo and redo:

java
CPDFEditManager editManager = readerView.getEditManager();
// undo
if (editManager.canUndo()) {
  editManager.undo();
}
// redo
if (editManager.canRedo()){
  editManager.redo();
}
kotlin
val editManager = readerView.editManager
// undo
if (editManager.canUndo()){
  editManager.undo()
}
// redo
if(editManager.canRedo()){
  editManager.redo()
}