4
string s="<html><body>..some html code..</body></html>";

How to print document without PrintDialog?

Output: ...some html code...

5
  • possible duplicate of HTML / Javascript One Click Print (no dialogs) Commented Aug 25, 2015 at 6:58
  • ASP.NET? Winforms? Wpf? Commented Aug 25, 2015 at 7:02
  • Its not clear what you are asking, what do you mean by print? Commented Aug 25, 2015 at 7:30
  • To print from a printer Commented Aug 25, 2015 at 7:35
  • did you see that? (Edit:Edit:WinForm) Commented Aug 25, 2015 at 10:13

1 Answer 1

4

As I understood you correctly, you need WebBrowser class:

WebBrowser webBrowser = new WebBrowser();
void Print(string str)
{
   webBrowser.DocumentText = str;
   webBrowser.DocumentCompleted += webBrowser_DocumentCompleted;
}
void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
   webBrowser.Print();
}
Sign up to request clarification or add additional context in comments.

1 Comment

this will popup the print dialog.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.