Program select printer to print from WebBrowser component

Good time of day!

need to programmatically print the document in the WebBrowser, and the printer is the default printer on the system.
How to programmatically invoke a dialog for selecting the printer know software to choose.
How to programmatically change the default printer, and then to return to the place also know (this now works) but I would like not changing the default printer.
It is clear that how to print, too.

Ideally, we would like to associate WebBroser and System.Drawing.Printing.PrintDocument in which the printer selection is not questioned.

Tell me, maybe someone already butted with this problem.

Thank you.
October 3rd 19 at 03:47
4 answers
October 3rd 19 at 03:49

If I understand correctly you need from the page loaded in the WebBrowser control to send a command in C# code to configure the printer and make a print. If so, then you have the question is how to call this code from the page. See here. The printer is specified via the property System.Drawing.Printing.PrintDocument.PrinterSettings.PrinterName, without dialogue.

Or specify exactly what you want.
October 3rd 19 at 03:51
The idea is to use JavaScript to send document to print from the WebControl on desired printer work in the sharp smells great crutch, I'm not talking that every document will have this script stuff.
Maybe I'm not good enough described the challenge:
The main idea, while in sharp to load in the WebBrowser control the html page and send it to the printer while at the same time, the sharp. Using JavaScript of course you can, but it hurts like all fucked up smells. And how do You imagine the setting of the printer through the System.Drawing.Printing.PrintDocument.PrinterSettings.If PrintDocument PrinterName and document in WebBrowser not connected in any way?
October 3rd 19 at 03:53
It seems I was too quick to advise PrintDocument. Also found a way for you through changing the default printer. Do not tell me this works how stable or just have a desire to do more right?
October 3rd 19 at 03:55
First and foremost, it's just ugly. Secondly, change the default printer there is always a delay (especially on the first call). Have to do a loop polling and waiting for change to happen. Again, hypothetically, if someone wants to print in parallel and waits for another printer by default, etc. The project is a serious and crutches do not want to write.

Find more questions by tags .NETC#