在WebBrowserControl(WinForm)C#中打开pdf时出现问题 [英] Problem when opening pdf in WebBrowserControl (WinForm) C#

查看:231
本文介绍了在WebBrowserControl(WinForm)C#中打开pdf时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



这是我的第一篇文章所以我想说,这是一个多么好的社区。

我有一个问题打开带参数的pdf时使用WebBrowserControl。



我称之为:

Hello guys,

this is my first post so I wanted to say, what a great community.
I have a problem with a WebBrowserControl when opening a pdf with parameters.

I call it like this:

var url = new Uri("C:\\tmp\\MyPdf.pdf#navpanes=0&toolbar=0");
WebBrowserControl1.Navigate(url);





它工作正常,直到我再次使用相同的命令。

由于adobe acrobat背景,WebBrowserControl变灰。



我试图用WebBrowserControl1.Navigate(大约:空白)重置页面再次重新开放,但这也没有用。



Greets

Max



It is working, without any problems until I use the same command again.
The WebBrowserControl gets gray because of the adobe acrobat background.

I tried to reset the page with WebBrowserControl1.Navigate(about:blank) before reopening again, but this was also not working.

Greets
Max

推荐答案

我有一个解决方案。试试这个。>
首先添加一个面板来嵌入它所在的webbrowser。

然后用这个方法打开页面

I have an solution.
try this.
First add an panel for imbeding the webbrowser it's in.
Then use this method for open the page
void OpenWebPage(ref WebBrowser _webBrowser,string _link)
       {
           if (!_webBrowser.IsDisposed)
               _webBrowser.Dispose();

           _webBrowser = new WebBrowser();
           panel2.Controls.Add(_webBrowser);
           _webBrowser.Dock = DockStyle.Fill;
           _webBrowser.Show();
           _webBrowser.Navigate(_link);
       }





点击这样。



click like this.

private void button1_Click(object sender, EventArgs e)
        {
            OpenWebPage(ref webBrwser, "C:\\tmp\\typescript.pdf#navpanes=0&toolbar=0");
        }        


这篇关于在WebBrowserControl(WinForm)C#中打开pdf时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆