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

Change freetextannotation text automatically upon edit

Hi, I would like to add text programatically inside a free text annotation. 

3 Replies

JP Jean Philippe Gagliardi July 17, 2019 09:18 PM UTC

In particular, when the annotation loses focus, I would like to check if the text of the annotation contains a specific sub string and if not, I would like to add it programatically inside the annotation. 


JP Jean Philippe Gagliardi July 17, 2019 09:22 PM UTC

I really do not have a clue how to do this.

Thank you

note: Sorry for multiple replies, I had a hard time with a (word or url not accepted in this forum thing...) my post was much longer...


AS Aravindh Sathiyamoorthy Syncfusion Team July 18, 2019 04:44 PM UTC

Hi Jean, 
 
We do not have support to add the annotations directly in the UI through code behind. To view the changes in UI, we need to save and reload the PdfLoadedDocument object in the PdfViewerControl as mentioned in the below code snippet.  
 
  
RectangleF rectangle = new RectangleF(left, top, width, height);  
PdfRectangleAnnotation rectangleAnnot = new PdfRectangleAnnotation(rectangle, "Rectangle annotation");  
rectangleAnnot.Border.BorderWidth = 4;  
rectangleAnnot.Border.BorderStyle = PdfBorderStyle.Solid;  
PdfViewerControl.LoadedDocument.Pages[0].Annotations.Add(rectangleAnnot);  
PdfViewerControl.LoadedDocument.Save(“output.pdf”); 
PdfViewerControl.Unload(true); 
PdfViewerControl.Load(“output.pdf”); 
  
We created a sample for the same and it can be downloaded in the below link,  
 
 
Kindly let us know whether the above details fulfil your requirement. 
 
Regards, 
 
Aravindh Sathiyamoorthy. 


Loader.
Up arrow icon