Undo and redo annotations in Blazor SfPdfViewer
12 May 20261 minute to read
The Blazor SfPdfViewer supports undo and redo for annotations.

Undo and redo actions can be performed by using either of the following methods:
- Using keyboard shortcuts (desktop):
After performing an annotation action, pressCtrl+Zto undo andCtrl+Yto redo on Windows and Linux. On macOS, useCommand+Zto undo andCommand+Shift+Zto redo. - Using the toolbar:
Use the Undo and Redo tools in the toolbar. - Programmatically:
Call the UndoAsync and RedoAsync methods from the client side.
Programmatic Undo and Redo
Refer to the following code snippet to call undo and redo actions programmatically.
@using Syncfusion.Blazor.Buttons
@using Syncfusion.Blazor.SfPdfViewer
<div style="margin-bottom: 8px;">
<SfButton OnClick="UndoAnnotation">Undo</SfButton>
<SfButton OnClick="RedoAnnotation">Redo</SfButton>
</div>
<SfPdfViewer2 @ref="viewer"
DocumentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
Height="650px"
Width="100%">
</SfPdfViewer2>
@code {
SfPdfViewer2 viewer;
public async void UndoAnnotation(MouseEventArgs args)
{
await viewer.UndoAsync();
}
public async void RedoAnnotation(MouseEventArgs args)
{
await viewer.RedoAsync();
}
}