阻止wpf WebBrowser显示其他确认

时间:2018-06-28 22:11:18

标签: c# wpf webbrowser-control

我正在使用WPF WebBroser控件显示pdf。但是我不希望Web浏览器显示其他确认信息,比如说要打开或保存此文件。我希望它直接打开pdf。请帮忙。这是我正在使用的代码

Open Confirmation

编辑:现在看完一些文章之后,我正在创建一个html字符串,但是当我尝试使用浏览器打开该字符串时。NavigateToString(fullhtml);它显示我空白。请帮忙。

  public void ShowReportInNewWindow(string path)
        {
            string htmlopen = @"<html>
                        <head>
                        <object classid=""clsid:ca8a9780-280d-11cf-a24d-444553540000"" id=""pdf1"" 
                        type=""application/pdf""
                         style=""width:100%; height:100%""
                        data=""{0}"">";

            string htmlclose = @"</object>
                            </body>
                             </html>";

            string fullhtml = string.Format(htmlopen, path) + htmlclose;
            fullhtml = fullhtml.Replace("\r", string.Empty);
            fullhtml = fullhtml.Replace("\n", string.Empty);
            Window window = new Window();
            WebBrowser browser = new WebBrowser();
            browser.NavigateToString(fullhtml);
            window.Content = browser;
            window.Title = Path.GetFileName(path);
            window.Owner = Window.GetWindow(this);
            window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            window.ShowDialog();
        }

0 个答案:

没有答案
相关问题