We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Add and remove annotattion programmatically

Hello,

I would like to be able to add and remove an annotation programmatically in an opened SfPdfViewer, so that the viewer is automatically refreshed with the new annotation.

Is it possible to do in UWP ?

Thanks

10 Replies

AS Aravinth Sampath Syncfusion Team December 21, 2016 04:22 PM UTC

Hi Courtoy, 
 
Thank you for using Syncfusion product. 
 
We can able to add and remove annotation programmatically in SfPdfViewer control. We have created simple sample for adding annotation and it can be downloaded from the below link 
 
 
Please try the above sample and revert us with more details on your requirement if your requirement is differed from the provided sample. 
 
Regards, 
Aravinth 



PC Pierre Courtoy January 2, 2017 02:45 PM UTC

Thanks for the support.

I tried the demo but I have a problem.

What I want to do is exactly what is done in the last method of MainPage.xaml.cs => button_Click

But when I try to add a two annotations in this way, there is an ArgumentNullException (in the demo).
Do you know what causes the bug ?

And I would like to be able to highlight and strikethrough text, but when I create an annotation, it uses all the surface I gave, not just the surface where there is text. Is it possible to know where there is text ?

Thanks for your help.

Pierre Courtoy


AS Aravinth Sampath Syncfusion Team January 3, 2017 02:47 PM UTC

Hi Pierre, 
 
Please find the details of your queries from the below table, 
 
Query 
Details 
I tried the demo but I have a problem. 
 
What I want to do is exactly what is done in the last method of MainPage.xaml.cs => button_Click 
 
But when I try to add a two annotations in this way, there is an ArgumentNullException (in the demo). 
Do you know what causes the bug ? 
 
We are unable to reproduce the mentioned issue. We can able to add multiple annotations in a PDF document. Here we have prepared a sample which includes multiple annotations in the single page of a PDF document. Please modify this sample or provide us a sample to reproduce the mentioned issue. This will be helpful for us to look in to this issue. 
And I would like to be able to highlight and strikethrough text, but when I create an annotation, it uses all the surface I gave, not just the surface where there is text. Is it possible to know where there is text ? 
The co-ordinates of the text can be get from the GetTextCoordinates() method of PdfViewerControl. Using the coordinates, we can add highlight annotation to the text. Please find the code snippet to get the coordinates of the particular text. 
 
>>>>>>>>>>>>>>>>>> 
pdfViewer.GetTextCoordinates("1D/Linear BarCodes", 0, out coords); 
>>>>>>>>>>>>>>>>>>>>>>>> 
 
We have prepared a sample using which you add the highlight annotation to the text programmatically. 
 
Please find the sample from the below link, 
 
 
Please let us know if you have any concerns. 
 
Regards, 
Aravinth 



PC Pierre Courtoy January 3, 2017 02:53 PM UTC

Hi Aravinth,

For the bug, I just downloaded again the sample (http://www.syncfusion.com/downloads/support/directtrac/general/ze/PdfViewer_UWP1736746709 ), runs it and clicked on the "Add Annotation" button on the middle of the screen.

Since it adds an annotation programmatically in an open pdf viewer, that is exactly what I'm looking for.

For the way to get the coordinate, thanks for the sample, I will test that.

Pierre Courtoy


PC Pierre Courtoy January 3, 2017 03:47 PM UTC

Hi Aravinth,

I've just tested the GetTextCoordinates but that's not quite what I need.

I need to get the coordinates of a text in a selected zone.
And in the new sample you send, I have the same crash when you click twice on the "Add annotation" button.

Thanks for your help,

Pierre Courtoy


RL Renaud Laloire January 5, 2017 10:03 AM UTC

Hi,

I also have a ArgumentNullException as soon as I add the second annotion with your sample.

Do you have any fix for this ? We need to be able to add more than one annotation at a time.

Cheers,

Renaud


AS Aravinth Sampath Syncfusion Team January 6, 2017 11:01 AM UTC

Hi Pierre, 
 
Please find the details of your queries from the below table, 
 
Queries 
Details 
 
For the bug, I just downloaded again the sample (http://www.syncfusion.com/downloads/support/directtrac/general/ze/PdfViewer_UWP1736746709 ), runs it and clicked on the "Add Annotation" button on the middle of the screen. 
 
Since it adds an annotation programmatically in an open pdf viewer, that is exactly what I'm looking for. 
We were able to reproduce the reported issue, and we have fixed it my modifying the sample. The modified sample can be downloaded from the below link. 
 
 
Please try this sample and let us know if you face any issues, 
 
I've just tested the GetTextCoordinates but that's not quite what I need. 
 
I need to get the coordinates of a text in a selected zone. 
 
Can you please provide us the more details on this requirement? 
 
Are you trying to get the coordinates of the text using text selection or using annotations? 
 
It will be helpful for us to analyze more and assist you better on this. 
 
Please let us know if you have any concerns. 
 
Regards, 
Aravinth 



PC Pierre Courtoy January 6, 2017 11:17 AM UTC

Hi Aravinth,

I've just tested the new sample but I see that you reload the base document before adding the annotation. In my case, I need to be able to load only one time the base document (via url or path) and add annotation multiple times. 

So I need to be able to save multiple times without having to load the base document again.

So the sample can't really help me.


And the second point (getcoordinates) is of less importance for me.

Thanks for your help,


RL Renaud Laloire January 9, 2017 08:52 AM UTC

Same for me : when not reloading the document, I can only add one annotation without crashing. As soon as I add a second one, it crashes.

Syncfusion, can you see thaArgumentNullException  ?

Regards,

Renaud


AS Aravinth Sampath Syncfusion Team January 12, 2017 02:28 PM UTC

Hi Customer, 

A support incident to track the status of reported issue “Issue in adding and removing annotation programmatically without loading multiple times in SfPdfViewer control, has been created individually under your account. Please log on to our support website to check for further updates.  
 
 
Regards, 
Aravinth 


Loader.
Live Chat Icon For mobile
Up arrow icon