0

I have a web application that produces various reports/documents/labels that need printing. Depending on the report a different local printer is used. Most go via the A4 laser, but some need to be printed on 1 of 2 different local label printers. Each PC can have different named local lable printers.

So far, the users have had to select the correct printer when printing. But having looked at WebView2 I thought I could use that in a c# windows forms app. My thought was that since the app would know what webpage is calling the print request, it could then direct it to the correct printer based on the url.

Does anyone know if this this is possible?

Or is there a way to direct a print job to a named printer when printing from the web? Short of installing a service on to each PC?

Edit: My question is clearly not clear. I know how to set the printer using c#, but I haven't used webview2 and wanted to know if the c# application would know or get what the current URL is with query string. I would like set the printer based on that.

jimmy
  • 709
  • 3
  • 15
  • 33
  • Does this answer your question? [Programmatically select a printer in PrintDialog](https://stackoverflow.com/questions/23392779/programmatically-select-a-printer-in-printdialog) – Poul Bak Feb 22 '21 at 22:27
  • Thanks for the suggestion, and maybe my question is a little ambiguous. I know how to set the printer using c#, but I haven't used webview2 and wanted to know if the c# application would know what the current URL is with query string. I would like set the printer based on that. – jimmy Feb 26 '21 at 09:36
  • I know this is an older question, but you don't print with the control WebView2 like you would with the older WebBrowser. You'd hook into a javascript event and do web message, or just invoke the browser's print functionality. You do know the current URL if you go that route. – Nikki9696 Apr 26 '21 at 17:37

0 Answers0