1
votes

I'm printing html documents using a .net webbrowser control and I want to be able to show the print dialog once so the user can choose their printer.

Is there any way to show a print dialog without showing it every time the webbrowser control prints?

Is it possible to use a printdocument and somehow pass it's settings to the webbrowser object?

1

1 Answers

2
votes

You can pass arguments to Print-command that states whether to show the print dialog or not. For example, if m_webBrowser is your WebBrowser-control:

short flags = 0x03; // PRINT_DONTBOTHERUSER and PRINT_WAITFORCOMPLETION
bool showDialog = false;
((mshtml.HTMLDocumentClass)m_webBrowser.Document).execCommand("Print", showDialog, flags);

More info (surprisingly) from MSDN entry for IDM_PRINT Command ID.