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.