WebView2 not respecting HiddenPdfToolbarItems in popup.

Christian Cristofori 1 Reputation point

Settings WebView2 (version 96.0.1054.62) as this:

_webView.CoreWebView2.Settings.HiddenPdfToolbarItems = CoreWebView2PdfToolbarItems.Save | CoreWebView2PdfToolbarItems.SaveAs;

The toolbar is correctly set as you can see from the following 167521-user-manual.png attachment.

But if the user pops up anywhere in the document he still has the opportunity to save the document.

Microsoft Edge
Microsoft Edge
A Microsoft cross-platform web browser that provides privacy, learning, and accessibility tools.
2,111 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. XuDong Peng-MSFT 10,096 Reputation points Microsoft Vendor

    Hi @Christian Cristofori ,

    As the property name of this setting is, it is used to hide the icon display of the PDF toolbar, not the context menu. And if you don't want the user to save as or print through the menu function in the right mouse button, you can try disabling this menu with this line of code:

    webView.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;  

    Or you can try referring to this thread to override the context menu. But this also doesn't completely prevent users from saving as or printing. They can still be done with keyboard shortcuts such as Ctrl+S or Ctrl+P.

    Best regards,
    Xudong Peng

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

  2. Christian Cristofori 1 Reputation point

    This workaround is not applicable, since this would disable the popup menus anywhere in the VW2 preventing the user to be able to use the rest of the application.

    Thank you anyway.