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

How to remove default context menu items and add my custom items?

I would like to implement customized contextMenu when user selects text and presses right mouse button. I have found some information bits, but haven't succeeded, here is my attempt:

<ejs-pdfviewer id="pdfviewer" serviceUrl="/api/PdfViewer" enableToolbar="true"

   documentPath="PDF_Succinctly.pdf"

   contextMenuSettings="@(new Syncfusion.EJ2.PdfViewer.PdfViewerContextMenuSettings

   { ContextMenuItems = new string[] {"ItemA", "ItemB" },

   })"

</ejs-pdfviewer>

This does not work and I am not sure if I have use wrong syntax  or this is not possible by design?



7 Replies

VV Visvesvar Venkatesan Syncfusion Team April 19, 2023 11:43 AM UTC

It is possible only to remove the items from the context menu and it is not possible to add new items or customized items.


Kindly find the sample and code snippet for removing the context menu items.


Code Snippet:


  function documentLoaded(args) {

               var viewer = document.getElementById('pdfviewer').ej2_instances[0];

       //viewer.contextMenuOption = 'None';

       console.log(viewer);

       viewer.contextMenuSettings = { contextMenuAction: 'RightClick', contextMenuItems:[16,0]};

      

};


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ASPNET-_context_menu-1012732887.zip


Kindly try this and let us know if you have any concerns.



JD Janis Dzenis April 19, 2023 02:41 PM UTC

Hi Visvesvar,

Thank you for the answer. Does this " and it is not possible to add new items or customized items " apply only to selected text context menu or also to selected annotations context menu?





VV Visvesvar Venkatesan Syncfusion Team April 20, 2023 09:14 AM UTC

Thank you for your update.


Yes, it is not possible to customize the context menu which are applicable to annotations. Text markup, and form fields.




JD Janis Dzenis April 20, 2023 12:33 PM UTC

Hi Visvesvar,

Thank you for information. One last question - is this a limitation of ASP .NET Core version or is it like this across other platforms as well? If I remember correctly, I somewhere saw that Xamarin (not 100% sure) version had option to use custom menu items in pdfViewer.

Regards,

Janis



AC ArunKumar Chandrakesan Syncfusion Team April 21, 2023 06:16 AM UTC

All the web platform components doesn't have this support. We will check the feasibility of considering this as a feature request and get back to you with further updates

on April 25, 2023.



JD Janis Dzenis April 24, 2023 11:08 AM UTC

Hi ArunKumar,

Thank you for the answer. We can close this ticket now.


Regards,

Janis



VV Visvesvar Venkatesan Syncfusion Team April 25, 2023 06:02 AM UTC

Thank you for your update. We are closing this ticket.


Loader.
Live Chat Icon For mobile
Up arrow icon