WebView2删除pdf上方的空间(工具栏)

发布于 2025-01-23 08:27:25 字数 1251 浏览 4 评论 0原文

我正在WebView2控件中加载PDF,这是我的代码:

Imports Microsoft.Web.WebView2.Core

Public Class Form1
  Private Async Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    AddHandler webView.CoreWebView2InitializationCompleted, AddressOf WebView_CoreWebView2InitializationCompleted
    AddHandler webView.NavigationCompleted, AddressOf WebView_NavigationCompleted

    Await InitializeAsync()

  End Sub

  Private Sub WebView_NavigationCompleted(sender As Object, e As CoreWebView2NavigationCompletedEventArgs)

  End Sub

  Private Async Function InitializeAsync() As Task
    Await webView.EnsureCoreWebView2Async(Nothing)
    webView.Source = New Uri("file:///D:/123.pdf")
  End Function

  Private Sub WebView_CoreWebView2InitializationCompleted(ByVal sender As Object, ByVal e As Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs)

    webView.CoreWebView2.Settings.HiddenPdfToolbarItems = CoreWebView2PdfToolbarItems.None

  End Sub

End Class

现在我想删除PDF上方的黑空间(工具栏),查看:

“

I am loading PDF in WebView2 control, here is my code:

Imports Microsoft.Web.WebView2.Core

Public Class Form1
  Private Async Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    AddHandler webView.CoreWebView2InitializationCompleted, AddressOf WebView_CoreWebView2InitializationCompleted
    AddHandler webView.NavigationCompleted, AddressOf WebView_NavigationCompleted

    Await InitializeAsync()

  End Sub

  Private Sub WebView_NavigationCompleted(sender As Object, e As CoreWebView2NavigationCompletedEventArgs)

  End Sub

  Private Async Function InitializeAsync() As Task
    Await webView.EnsureCoreWebView2Async(Nothing)
    webView.Source = New Uri("file:///D:/123.pdf")
  End Function

  Private Sub WebView_CoreWebView2InitializationCompleted(ByVal sender As Object, ByVal e As Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs)

    webView.CoreWebView2.Settings.HiddenPdfToolbarItems = CoreWebView2PdfToolbarItems.None

  End Sub

End Class

Now I want to remove the black space (toolbar) that is above that PDF, look:

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

中二柚 2025-01-30 08:27:25

看起来这是一个Winforms项目,但是根据您的屏幕截图,我认为您可能会错误地设置WebView2控件,例如 this ,您提到的问题发生在WebView2 Control不会铺平整个窗口时。

因此,您需要确认WebView2控件的大小及其在整个窗口中的显示方式,例如:

“在此处输入图像说明”

It looks like this is a winforms project, but based on your screenshots, I think you may have the webView2 control set up incorrectly, something like this, the issue you mentioned occurs when the WebView2 control does not tile the entire window.

So you need to confirm the size of the WebView2 control and how it will appear in the entire window, like this:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文