ComPDF React Native - v3.0.0
    Preparing search index...

    Class CPDFAnnotationHistoryManager

    Manages the undo and redo history for PDF annotation actions within a viewer component.

    This class extends CPDFHistoryManagerBase and provides methods to interact with the annotation history, including checking if undo/redo actions are available and performing those actions. It also allows registering a listener to monitor changes in the annotation history state.

    Usage:

    • Instantiate with a reference to the PDF viewer component.
    • Use canUndo() and canRedo() to check if undo/redo actions are available.
    • Call undo() and redo() to perform undo/redo operations.
    • Register a listener with setOnHistoryStateChangedListener() to be notified when the history state changes.
    const historyManager = pdfReader._annotationsHistoryManager;
    historyManager.setOnHistoryStateChangedListener((canUndo, canRedo) => {
    // Update UI based on undo/redo availability
    });

    Hierarchy

    • CPDFHistoryManagerBase
      • CPDFAnnotationHistoryManager
    Index

    Constructors

    Methods

    • Parameters

      • event: any

      Returns void

    • Sets a listener to monitor changes in annotation history state. This should be called during annotation operations to indicate whether undo or redo actions are available.

      Parameters

      • listener: (canUndo: boolean, canRedo: boolean) => void

        A callback function with two parameters: canUndo (whether undo is available) and canRedo (whether redo is available).

      Returns void

      const historyManager = pdfReader._annotationsHistoryManager;
      historyManager.setOnHistoryStateChangedListener((canUndo, canRedo) => {
      // Update UI based on undo/redo availability
      });
    • Checks if an undo operation is possible.

      Returns Promise<boolean>

      A promise that resolves to true if an undo operation is possible, otherwise false.

      const manager = pdfReader._annotationsHistoryManager
      await manager.canUndo();
    • Checks if an undo operation is possible.

      Returns Promise<boolean>

      A promise that resolves to true if a redo operation is possible, otherwise false.

      const manager = pdfReader._annotationsHistoryManager
      await manager.canRedo();
    • Checks if a redo operation is possible.

      Returns Promise<void>

      A promise that resolves when the undo operation is complete.

      const manager = pdfReader._annotationsHistoryManager
      await manager.redo();
    • Performs a redo operation on the annotation history.

      Returns Promise<void>

      A promise that resolves when the redo operation is complete.

      const manager = pdfReader._annotationsHistoryManager
      await manager.redo();