ClearAnnotations function is missing

Hello everyone,


I have come across an issue while using the Syncfusion PdfViewerControl. It appears that the WPF version of the PdfViewerControl does not have functions like ClearAnnotations or ClearAllAnnotations to clear the annotations. Instead, annotations can only be deleted using the DeleteAnnotation function.


However, similar functionality has already been implemented in Xamarin. I was wondering if Syncfusion has plans to add this feature to the WPF version? Alternatively, it would be helpful to have a function to retrieve all annotations so that we can call the DeleteAnnotation function and achieve a similar clearing operation.


Thank you.


8 Replies 1 reply marked as answer

RH Rhyme June 27, 2023 09:06 AM UTC

Hello everyone,


I have encountered an issue while using shape annotations in my program. When I use ink annotations, the program works fine, and it also works fine when I use shape annotations. However, when I delete the shape annotations and then try to use them again, they fail to work, while ink annotations continue to work normally.


I triggered the issue in the following sequence: 

  1. Click on the Pdf View. 
  2. Click on Ink Annotation and draw any shape. 
  3. Click on Line Annotation and draw a line. 
  4. Select Delete Annotation, and then select the just-drawn annotation to delete it. 
  5. Deselect Delete Annotation and click on Ink Annotation. (Now you can draw normally). 
  6. Click on Line Annotation again, but the straight line cannot be drawn (while it can be drawn if you click on Ink Annotation).


I am not sure what caused this issue. The relevant source code has been uploaded to the attachment. Please help me resolve this issue. Thank you.


Attachment: Syncfusion_PDF_354b5e2b.zip


MS Manigandan Shanmugam Syncfusion Team June 27, 2023 12:06 PM UTC

Rhyme,


Queries

Response

1. I have come across an issue while using the Syncfusion PdfViewerControl. It appears that the WPF version of the PdfViewerControl does not have functions like ClearAnnotations or ClearAllAnnotations to clear the annotations. Instead, annotations can only be deleted using the DeleteAnnotation function.

At present, we don’t have support for removing all the annotations in the document, using a single API in our WPF PdfViewerControl. However, we can achieve this by using the PdfLoadedDocument instance programmatically. With the LoadedDocument property we can remove all the annotations in the document by iterating over the pages and then clearing the annotations collection. We have attached simple sample and code snippet below to remove all annotation in the document using LoadedDocument.

            for(int i = 0; i < pdfViewer.LoadedDocument.Pages.Count; i++)

            {

                pdfViewer.LoadedDocument.Pages[i].Annotations.Clear();

            }

Regarding API to delete all annotations in the document in WPF PdfViewer, similar to Xamarin PdfViewer. We will analyze and update further on July 30, 2023.

 

2. I have encountered an issue while using shape annotations in my program. When I use ink annotations, the program works fine, and it also works fine when I use shape annotations. However, when I delete the shape annotations and then try to use them again, they fail to work, while ink annotations continue to work normally.

We have already resolved this reported issue in our latest release. Please upgrade to the latest version, v22.1.34, to get the reported issue resolved.

Package link:

https://www.nuget.org/packages/Syncfusion.PdfViewer.WPF/22.1.34



Attachment: sample_6895d1da.zip

Marked as answer

RH Rhyme replied to Manigandan Shanmugam June 28, 2023 12:50 AM UTC

Manigandan, thank you for your quick reply and problem solving



MS Manigandan Shanmugam Syncfusion Team June 30, 2023 11:02 AM UTC

Rhyme, we have logged a feature request for “Removing all the annotations in the document, using a single API in our WPF PdfViewerControl”. We do not have any immediate plans to implement these features. At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision, technological feasibility, and customer interest. We will let you know when this feature is implemented.

You can now track the status of this feature request here,

https://www.syncfusion.com/feedback/44903/removing-all-the-annotations-in-the-document-using-a-single-api-in-our-wpf



RH Rhyme replied to Manigandan Shanmugam July 24, 2023 07:18 AM UTC

Hello, Manigandan:


I encountered some issues with clearing ink. After drawing any shape, I used the method you provided to clear the ink, and it worked well. However, after repeating this operation for about half an hour, the ink could not be cleared anymore. Could it be that my frequent operations caused it to not be cleared properly?


Please find below a screenshot of the error log that may be related to this issue:

WPS图片(1) (1).jpg



MS Manigandan Shanmugam Syncfusion Team July 25, 2023 02:01 PM UTC

Rhyme, From the stack trace you provided the reported issue is not occur while clearing the annotations, It occurs when you click the hyperlink within the document. The exception was raised  due to pdfviewer try to start the invalided link associated with the hyperlink clicked. However, there is a solution to resolve this issue by manually handling the hyperlink events using the PdfViewer_HyperlinkClicked event. In this event, we can handle the hyperlink manually by setting "e.handled" as true and preventing any further exceptions from being thrown. Please find the code snippet and attached sample for your reference.



     pdfViewer.HyperlinkClicked += PdfViewer_HyperlinkClicked;

  

        private void PdfViewer_HyperlinkClicked(object sender, Syncfusion.Windows.PdfViewer.HyperlinkClickedEventArgs e)

        {

            e.Handled = true;

        }



RH Rhyme replied to Manigandan Shanmugam July 26, 2023 12:46 AM UTC

Thank you, Manigandan. I will try to fix it using the method you provided.



MS Manigandan Shanmugam Syncfusion Team July 26, 2023 10:54 AM UTC

Most welcome, please try and let us know if you need any assistance.


Loader.
Up arrow icon