How to add custom annotations to the SfPdfViewer?

I need my app's users to be able to select some custom annotations that I have defined in the pdf viewer. That means like adding a shape such as circle or a line, in my pdf viewer I should be able to add some custom annotations that defined by me. I know user can import an annotation file from files but I need to be able to add them to the pdf viewer itself so that users can select them from the pdf viewer itself to add to the pdf document. ex:

Image_3998_1737525632365


1 Reply

BS Bharathi Selvam Syncfusion Team January 23, 2025 11:32 AM UTC

Hi Ruvindra,

Yes, it is possible to add custom annotations by programmatically setting the annotation mode or directly adding the annotations to the PDF. Based on our understanding, it seems you might be looking to implement your own custom toolbar for selecting and adding custom annotations (such as circles or lines). If this is the case, you could consider disabling the built-in toolbar and integrating your custom toolbar to meet your specific requirements.

To disable the build-in toolbar, please refer the below code :

  //Disable built-in toolbar

  pdfViewer.ShowToolbars = false;


If you want to allow users to continuously add circle annotations, you can set the annotation mode to "Circle" and disable it when the user finishes drawing. Alternatively, if you want to add a circle annotation at a specific location, you can create and add the annotation programmatically using the desired bounds.

Here’s a code snippet to set the annotation mode to "Circle":

// To set the annotation mode to circle

pdfViewer.AnnotationMode=AnnotationMode.Circle;

 

We support various annotation types, including ink, free text, text markups, shapes, sticky notes, and more. For additional information on how to use and add these annotations, please refer to the following documentation links:

Additionally, we have attached a sample along with a recorded video that demonstrates how to add circle annotations to a PDF. Kindly review the sample and video and let us know if they meet your requirements.

Regards,

Bharathi S


Attachment: PDFViewerDemo_b0d14d6d.zip

Loader.
Up arrow icon