我如何:在.NET 3.5 SP1中提供的WPF web浏览器打印? [英] How do I print from the wpf WebBrowser available in .net 3.5 SP1?

查看:118
本文介绍了我如何:在.NET 3.5 SP1中提供的WPF web浏览器打印?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前正在使用我们的WindowsFormsHost和打印应用一个WinForms WebBrowser控件通过调用WebBrowser.ShowPrintDialog()我们有这个问题,该对话框不会出现是模式和父窗口可以驳回导致问题如果打印稍后尝试。

we are currently using a winforms WebBrowser control in our app in a WindowsFormsHost and printing by calling 'WebBrowser.ShowPrintDialog()' We have an issue with this in that the dialog does not appear to be modal and the parent window can be dismissed causing issues if a print is later attempted.

我一直在寻找,希望他们有固定的做了类似的事情时,自己这个问题上的新的WPF WebBrowser控件,但可以找到没有办法从它打印。

I was looking at the new wpf webbrowser control in the hope that they will have fixed this issue when doing a similar thing themselves, but can find no way to print from it..

我发现这样做的人说话在线:

I found someone online talking of doing this:

        PrintDialog printDialog = new PrintDialog();
        printDialog.PrintDocument(((IDocumentPaginatorSource)webBrowser.Document).DocumentPaginator, "My App");

但抛出异常的WebBrowser.Document不支持IDocumentPaginatorSource接口。

but this throws an exception as the WebBrowser.Document does not support the IDocumentPaginatorSource interface.

有什么方法可以让我从WPF Web浏览器控制打印?

Is there any way I can print from the wpf web browser control?

感谢

推荐答案

我用这,和它的作品:

    mshtml.IHTMLDocument2 doc = webBrowser.Document as mshtml.IHTMLDocument2;
    doc.execCommand("Print", true, null);

这篇关于我如何:在.NET 3.5 SP1中提供的WPF web浏览器打印?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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