How can I add a image with editor to a PDF file in Pdf Viewer?

Hi, 

I'm using PDF Viewer, I want to create a feature that allows user can add an image to pdf file in UI. 

I referred the link to insert image as a signature. So, How can I add Context Menu for this signature to perform some actions with it such as bring to front, send to back, change image properties,... (please see the below screen shot).


Image_7457_1724040705428

If you have any ideas for this requirement, please tell me. 

Many thanks and regards,

TH


5 Replies 1 reply marked as answer

MA ManojKumar Arumugasamy Syncfusion Team August 19, 2024 11:26 AM UTC

Hi Thanh,

You can add the image as an annotation and also move, resize, or adjust the opacity of the annotations. The custom context menu should be implemented at the sample level after selecting the annotations using the AnnotationSelected event. These operations can also be carried out through the context menu.

However, please note that when image annotations are selected, they are automatically brought above all other annotations and will return to their original position once deselected. This is the default behavior and cannot be manually customized at the application level.

Could you please explain the complete requirements for editing images in the PDF viewer? Also, you can try editing the images to your preference within the application before adding it as an annotation to the PDF viewer, ensuring that it meet your desired specifications.

Regards,

Manoj Kumar



TH Thanh Hai Dang August 19, 2024 02:56 PM UTC

Hi  Manoj ,

For simple, I just want to know how to add context menu for the Selected Annotation. 

Thanks and regards,

TH



MA ManojKumar Arumugasamy Syncfusion Team August 20, 2024 03:26 PM UTC

Hi Thanh,

You can add the context menu to the sample by using the AnnotationSelected event. We can have the annotation position in the event, and with the conversion of the PDF point to the client point, we can have the client (PDF viewer viewport) position. With this,  we can position the context menu according to the position of the annotations. We have added a simple code snippet for your reference.


PdfViewer.AnnotationSelected += PdfViewer_AnnotationSelected;

PdfViewer.AnnotationDeselected += PdfViewer_AnnotationDeselected;

 

    private void PdfViewer_AnnotationDeselected(object sender, AnnotationEventArgs e)

    {

        OptionsLayout.IsVisible = false;

    }

private void PdfViewer_AnnotationSelected(object sender, AnnotationEventArgs e)

{

    Point optionsBounds= new Point();

   if( e.Annotation is StampAnnotation stampAnnotation)

    {

        int pageNumber = stampAnnotation.PageNumber;

        RectF annotationBounds = stampAnnotation.Bounds;

        Point pagePoint = new Point(annotationBounds.X, annotationBounds.Y);

        optionsBounds = PdfViewer.ConvertPagePointToClientPoint(pagePoint, pageNumber);

    }

    OptionsLayout.IsVisible=true;

    OptionsLayout.SetLayoutBounds(optionsListView, new Rect(optionsBounds.X + optionsListView.WidthRequest, optionsBounds.Y+optionsListView.HeightRequest, optionsListView.Width, optionsListView.Height));

}


Note: We have this sample to get points and position the context menu of ink and stamp annotations.


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/194112Sample1740255311


Marked as answer

TH Thanh Hai Dang September 7, 2024 02:07 AM UTC

Hi Manjo,

Thank you for you support. I've created a workaround base on your example to resolve my issue.

However, I still want to Syncfusion team will be produce some solution for Annotation Context Menu.

Thank again



MM Manikandan Manickavasagam Syncfusion Team September 10, 2024 03:21 AM UTC

Hi Thanh,


Thanks for your feedback. Regarding your request to add a context menu for signature annotations to perform actions like bringing to front, sending to back, or changing image properties, you can achieve this using the existing API such as the AnnotationSelected event and converting PDF points to client points . If you're specifically looking for a built-in context menu for selected annotations, we currently do not have plans to provide a built-in context menu for selected annotations. However, we have observed similar functionality in other competitors where a context menu appears to edit, delete and some of other operation of annotations upon selection. Could you please confirm if a feature providing a context menu for editing and deleting annotations would meet your needs? If not, kindly let us know the specific options you would like to see in the annotation context menu. Your confirmation will be helpful for us to analyze this feature request better.


Regards,

Manikandan M


Loader.
Up arrow icon