How can I help you?
Annotation Events in Blazor SfPdfViewer Component
12 Feb 202614 minutes to read
Annotation events notify the application when annotations are added, selected, moved, resized, modified, or removed. Subscribe to these events by using the PdfViewerEvents tag inside the SfPdfViewer component.
| Name | Description |
|---|---|
| AddSignature | Triggers when a signature is added to a page. |
| AnnotationAdded | Triggers when an annotation is added to a page. |
| AnnotationMouseover | Triggers when the mouse pointer moves over an annotation. |
| AnnotationMoved | Triggers when an annotation is moved on a page. |
| AnnotationPropertiesChanged | Triggers when annotation properties are modified. |
| AnnotationRemoved | Triggers when an annotation is removed from a page. |
| AnnotationResized | Triggers when an annotation is resized on a page. |
| AnnotationSelected | Triggers when an annotation is selected on a page. |
| AnnotationUnselected | Triggers when an annotation is unselected on a page. |
| ExportFailed | Triggers when an annotation export fails. |
| ExportStarted | Triggers when annotation export starts. |
| ExportSucceed | Triggers when annotation export succeeds. |
| ImportFailed | Triggers when an annotation import fails. |
| ImportStarted | Triggers when annotation import starts. |
| ImportSucceed | Triggers when annotation import succeeds. |
| MoveSignature | Triggers when a signature is moved on a page. |
| OnAnnotationDoubleClick | Triggers when an annotation is double-clicked. |
| RemoveSignature | Triggers when a signature is removed from a page. |
| ResizeSignature | Triggers when a signature is resized on a page. |
| SignaturePropertiesChange | Triggers when signature properties are changed on a page. |
| SignatureSelected | Triggers when a signature is selected on a page. |
| SignatureUnselected | Triggers when a signature is unselected on a page. |
AddSignature event
The AddSignature event triggers when a signature is added to a page.
Event arguments
See AddSignatureEventArgs for properties such as Id, PageNumber, and Bounds.
The following example illustrates handling the AddSignature event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents AddSignature="@AddSignature"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task AddSignature(AddSignatureEventArgs args)
{
Console.WriteLine($"Added Signature ID: {args.Id}");
}
}AnnotationAdded event
The AnnotationAdded event triggers when an annotation is added to a page.
Event arguments
See AnnotationAddedEventArgs for details such as AnnotationId, AnnotationType, PageNumber, and Bounds.
The following example illustrates handling the AnnotationAdded event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents AnnotationAdded="@AnnotationAdded"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task AnnotationAdded(AnnotationAddEventArgs args)
{
Console.WriteLine($"Added Annotation ID: {args.AnnotationId}");
}
}AnnotationMouseover event
The AnnotationMouseover event triggers when the mouse pointer moves over an annotation.
Event arguments
See AnnotationMouseoverEventArgs for details such as AnnotationId, AnnotationType, PageNumber, and cursor position.
The following example illustrates handling the AnnotationMouseover event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents AnnotationMouseover="@AnnotationMouseover"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task AnnotationMouseover(AnnotationMouseoverEventArgs args)
{
Console.WriteLine($"Annotation Mouseover X: {args.X} and y: {args.X}");
}
}AnnotationMoved event
The AnnotationMoved event triggers when an annotation is moved on a page.
Event arguments
See AnnotationMovedEventArgs for details such as AnnotationId, PageNumber, PreviousBounds, and Bounds.
The following example illustrates handling the AnnotationMoved event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents AnnotationMoved="@AnnotationMoved"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task AnnotationMoved(AnnotationMoveEventArgs args)
{
Console.WriteLine($"Annotation Current Position: {args.CurrentPosition}");
}
}AnnotationPropertiesChanged event
The AnnotationPropertiesChanged event triggers when annotation properties are modified on a page.
Event arguments
See AnnotationPropertiesChangedEventArgs for details such as AnnotationId, PageNumber, changed property names, and old/new values.
The following example illustrates handling the AnnotationPropertiesChanged event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents AnnotationPropertiesChanged="@AnnotationPropertiesChanged"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task AnnotationPropertiesChanged(AnnotationPropertiesChangeEventArgs args)
{
Console.WriteLine($"Is Annotation Color Changed: {args.IsColorChanged}");
}
}AnnotationRemoved event
The AnnotationRemoved event triggers when an annotation is removed from a page.
Event arguments
See AnnotationRemovedEventArgs for details such as AnnotationId, AnnotationType, and PageNumber.
The following example illustrates handling the AnnotationRemoved event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents AnnotationRemoved="@AnnotationRemoved"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task AnnotationRemoved(AnnotationRemoveEventArgs args)
{
Console.WriteLine($"Removed Annotation ID: {args.AnnotationId}");
}
}AnnotationResized event
The AnnotationResized event triggers when an annotation is resized on a page.
Event arguments
See AnnotationResizedEventArgs for details such as AnnotationId, PageNumber, PreviousBounds, and Bounds.
The following example illustrates handling the AnnotationResized event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents AnnotationResized="@AnnotationResized"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task AnnotationResized(AnnotationResizeEventArgs args)
{
Console.WriteLine($"Resized Annotation ID: {args.AnnotationId}");
}
}AnnotationSelected event
The AnnotationSelected event triggers when an annotation is selected on a page.
Event arguments
See AnnotationSelectedEventArgs for details such as AnnotationId, AnnotationType, and PageNumber.
The following example illustrates handling the AnnotationSelected event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents AnnotationSelected="@AnnotationSelected"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task AnnotationSelected(AnnotationSelectEventArgs args)
{
Console.WriteLine($"Selected Annotation ID: {args.AnnotationId}");
}
}AnnotationUnselected event
The AnnotationUnselected event triggers when an annotation is unselected on a page.
Event arguments
See AnnotationUnselectedEventArgs for details such as AnnotationId, AnnotationType, and PageNumber.
The following example illustrates handling the AnnotationUnselected event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents AnnotationUnselected="@AnnotationUnselected"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task AnnotationUnselected(AnnotationUnselectEventArgs args)
{
Console.WriteLine($"UnSelected Annotation ID: {args.AnnotationId}");
}
}ExportFailed event
The ExportFailed event triggers when annotation export fails.
Event arguments
See ExportFailureEventArgs for details such as ErrorDetails.
The following example illustrates handling the ExportFailed event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents ExportFailed="@ExportFailed"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task ExportFailed(ExportFailureEventArgs args)
{
Console.WriteLine($"Error details: {args.ErrorDetails}");
}
}ExportStarted event
The ExportStarted event triggers when annotation export starts.
Event arguments
See ExportStartEventArgs for details about the export start event.
The following example illustrates handling the ExportStarted event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents ExportStarted="@ExportStarted"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task ExportStarted(ExportStartEventArgs args)
{
Console.WriteLine("Export Action Started");
}
}ExportSucceed event
The ExportSucceed event triggers when annotation export succeeds.
Event arguments
See ExportSuccessEventArgs for details such as FileName.
The following example illustrates handling the ExportSucceed event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents ExportSucceed="@ExportSucceed"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task ExportSucceed(ExportSuccessEventArgs args)
{
Console.WriteLine($"Exported File name : {args.FileName }");
}
}ImportFailed event
The ImportFailed event triggers when annotation import fails.
Event arguments
See ImportFailureEventArgs for details such as ErrorDetails.
The following example illustrates handling the ImportFailed event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents ImportFailed="@ImportFailed"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task ImportFailed(ImportFailureEventArgs args)
{
Console.WriteLine($"Error details: {args.ErrorDetails}");
}
}ImportStarted event
The ImportStarted event triggers when annotation import starts.
Event arguments
See ImportStartEventArgs for details about the import start event.
The following example illustrates handling the ImportStarted event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents ImportStarted="@ImportStarted"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task ImportStarted(ImportStartEventArgs args)
{
Console.WriteLine("Import Annotation Started");
}
}ImportSucceed event
The ImportSucceed event triggers when annotation import succeeds.
Event arguments
See ImportSuccessEventArgs for details about successful import.
The following example illustrates handling the ImportSucceed event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents ImportSucceed="@ImportSucceed"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task ImportSucceed(ImportSuccessEventArgs args)
{
Console.WriteLine("Annotation Imported Successfully");
}
}MoveSignature event
The MoveSignature event triggers when a signature is moved on a page.
Event arguments
See MoveSignatureEventArgs for details such as Id, PageNumber, PreviousBounds, and Bounds.
The following example illustrates handling the MoveSignature event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents MoveSignature="@MoveSignature"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task MoveSignature(MoveSignatureEventArgs args)
{
Console.WriteLine($"Moved Signture ID: {args.Id}");
}
}OnAnnotationDoubleClick event
The OnAnnotationDoubleClick event triggers when an annotation is double-clicked.
Event arguments
See AnnotationDoubleClickEventArgs for details such as AnnotationId, AnnotationType, PageNumber, and mouse position.
The following example illustrates handling the OnAnnotationDoubleClick event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents OnAnnotationDoubleClick="@OnAnnotationDoubleClick"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task OnAnnotationDoubleClick(AnnotationDoubleClickEventArgs args)
{
Console.WriteLine($"Double Clicked Annotation ID: {args.AnnotationId}");
}
}RemoveSignature event
The RemoveSignature event triggers when a signature is removed from a page.
Event arguments
See RemoveSignatureEventArgs for details such as Id and PageNumber.
The following example illustrates handling the RemoveSignature event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents RemoveSignature="@RemoveSignature"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task RemoveSignature(RemoveSignatureEventArgs args)
{
Console.WriteLine($"Removed Signature ID: {args.Id}");
}
}ResizeSignature event
The ResizeSignature event triggers when a signature is resized on a page.
Event arguments
See ResizeSignatureEventArgs for details such as Id, PageNumber, PreviousBounds, and Bounds.
The following example illustrates handling the ResizeSignature event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents ResizeSignature="@ResizeSignature"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task ResizeSignature(ResizeSignatureEventArgs args)
{
Console.WriteLine($"Resized Signature ID: {args.Id}");
}
}SignaturePropertiesChange event
The SignaturePropertiesChange event triggers when signature properties are changed on a page.
Event arguments
See SignaturePropertiesChangeEventArgs for details such as Id, PageNumber, and changed property values.
The following example illustrates handling the SignaturePropertiesChange event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents SignaturePropertiesChange="@SignaturePropertiesChange"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task SignaturePropertiesChange(SignaturePropertiesChangeEventArgs args)
{
Console.WriteLine($"Is Stroke Color Changed: {args.IsStrokeColorChanged}");
}
}SignatureSelected event
The SignatureSelected event triggers when a signature is selected on a page.
Event arguments
See SignatureSelectedEventArgs for details such as Id and PageNumber.
The following example illustrates handling the SignatureSelected event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents SignatureSelected="@SignatureSelected"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task SignatureSelected(SignatureSelectEventArgs args)
{
Console.WriteLine($"Selected Signture ID: {args.Id}");
}
}SignatureUnselected event
The SignatureUnselected event triggers when a signature is unselected on a page.
Event arguments
See SignatureUnselectedEventArgs for details such as Id and PageNumber.
The following example illustrates handling the SignatureUnselected event.
@using Syncfusion.Blazor.SfPdfViewer
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
<PdfViewerEvents SignatureUnselected="@SignatureUnselected"></PdfViewerEvents>
</SfPdfViewer2>
@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
public async Task SignatureUnselected(SignatureSelectEventArgs args)
{
Console.WriteLine($"UnSelected Signature ID: {args.Id}");
}
}