简体   繁体   English

如何在wpf中打印文件?

[英]How to Print File in wpf?

How to print a specified file in WPF using PrintDialog.PrintDocument() method? 如何使用PrintDialog.PrintDocument()方法在WPF中打印指定的文件?

I want to Print the html page using print Dialog. 我想使用print Dialog打印html页面。

You'll need some kind of an html renderer in order to print it. 你需要某种html渲染器来打印它。 either IEExplorer (look into shdocvw.dll and mshtml.dll) or Awesomium etc... good luck. IEExplorer(查看shdocvw.dll和mshtml.dll)或Awesomium等...祝你好运。

It is possible by using the Print() method of the WebBrowser Class in C# to do this. 可以通过在C#中使用WebBrowser类的Print()方法来执行此操作。 Just put the content to the WebBrowser Control like so: 只需将内容放到WebBrowser控件中,如下所示:

webBrowser1.DocumentContent = openfiledialog.FileName;

Then just call the "webBrowser1.Print();" 然后只需调用“webBrowser1.Print();” method. 方法。

http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.print.aspx http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.print.aspx

Refer MIcrosft.mshtml com object 请参阅MIcrosft.mshtml com对象

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM