Remove specific annotation

Hello,

Is there a way to remove only a specific annotation ? By an Id or is name, or somethink ?

Actually I remove all annotation before I add new one but I would like to remove only specific annoation thas is not up to date:

I know there is this method  exist await ViewerPdf.DeleteAnnotation() but I dont understand what it does.

My code :
 await ViewerPdf.DeleteAnnotations();
 await ViewerPdf.ImportAnnotation(jsonAnnotation.GenerateStream(), AnnotationDataFormat.Json);

Thanks,
Nicolas

2 Replies 1 reply marked as answer

DM Dhivyabharathi Mohan Syncfusion Team March 19, 2021 06:17 AM UTC

Hi Nicolas, 
 
In our PDF Viewer, we can get the id of the added annotation using annotationadded event and then we can delete the specific annotation by selecting the annotation using selectAnnotation(annotationId). Using deleteAnnotation method, we can delete the selected annotation as like below code snippet. We have shared the sample for your reference. 
 
 
Code snippet: 
 
 
<Syncfusion.Blazor.Buttons.SfButton OnClick="deleteAnnot"> deleteAnnotationById</Syncfusion.Blazor.Buttons.SfButton> 
 
 
<SfPdfViewer @ref="Viewer" DocumentPath="PDF_Succinctly.pdf" ServiceUrl="https://ej2services.syncfusion.com/production/web-services/api/pdfviewer" Height="500px" Width="1060px"> 
    <PdfViewerEvents AnnotationAdded="annotationAdd"></PdfViewerEvents> 
</SfPdfViewer> 
 
 
public void annotationAdd(AnnotationAddEventArgs args) 
        { 
            annotationId = args.AnnotationId; 
        } 
 
        public async void deleteAnnot() 
 
        { 
            await Viewer.SelectAnnotation(annotationId); 
            await Viewer.DeleteAnnotation(); 
        } 
 
 
 
Sample: 
 
 
 
Kindly try it and revert us, if you have any concerns. 
 
 
Regards, 
Dhivya. 


Marked as answer

NN Nicolas NOEL March 20, 2021 09:46 PM UTC

Hello
Thank you 
Nicolas

Loader.
Up arrow icon