DsPdfViewer provides 'Copy' and 'Print' options in its context menu, by default. However, the context menu options can be customized for other operations, like searching selected text by using different Web Search Engines.
The below image displays custom context menu when selected text is right clicked.
To configure custom context menu in DsPdfViewer:
Index.cshtml |
Copy Code
|
---|---|
viewer.options.onBeforeOpenContextMenu = function (items, mousePosition, viewer) { var selectedText = viewer.getSelectedText(); if (selectedText) { // Remove existent items: items.splice(0, items.length); // Add own menu items: items.push({ type: 'button', text: 'Search using Google', onClick: function () { window.open('http://www.google.com/search?q=' + encodeURI(selectedText), '_blank'); } }); items.push({ type: 'button', text: 'Search using Bing', onClick: function () { window.open('https://www.bing.com/search?q=' + encodeURI(selectedText), '_blank'); } }); } return true; }; |
Index.cshtml |
Copy Code
|
---|---|
var viewer = new DsPdfViewer("#root", { useNativeContextMenu: true }); |