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).
If you have any ideas for this requirement, please tell me.
Many thanks and regards,
TH
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
Hi Manoj ,
For simple, I just want to know how to add context menu for the Selected Annotation.
Thanks and regards,
TH
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
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
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