2015-08-25 45 views
2
string s="<html><body>..some html code..</body></html>"; 

如何在沒有PrintDialog的情況下打印文檔?C#html html中打印html文件的字符串

輸出:...一些HTML代碼...

+0

可能重複(無對話框)](http://stackoverflow.com/questions/9213660/html-javascript-one-click-print-no-dialogs) – Shaharyar

+0

ASP.NET?的WinForms? WPF? –

+0

不清楚你在問什麼,打印是什麼意思? – Jodrell

回答

2

正如我理解正確的話,你需要WebBrowser類:

WebBrowser webBrowser = new WebBrowser(); 
void Print(string str) 
{ 
    webBrowser.DocumentText = str; 
    webBrowser.DocumentCompleted += webBrowser_DocumentCompleted; 
} 
void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) 
{ 
    webBrowser.Print(); 
} 
[HTML/JavaScript的一個鍵打印的
+0

謝謝.Sposibo bolwe –