title: How to print HTML without WebBrowser control and Acrobat window?
body: <p>I know my question is not focused on a precise problem but Google ran out of results. I'm trying to make a little app in Visual Basic .Net and have a HTML string which needs to be printed to a specific printer, and the problem is that i've tried to:</p>
  
  <ul>
  <li>write out to a HTML file then print it with a WebBrowser: the problem is that i can't print to a specific printer, only to the default one.</li>
  <li>convert it to a PDF with htmlToPdf package but: (1) it needs Acrobat Reader AND file association in Windows, (2) it opens the Acrobat Reader which is not quite professional.</li>
  </ul>
  
  <p><strong>EDIT</strong></p>
  
  <p>Thanks to a solution provided by the first commenter, i've made it partially. The problem is that the first document is printed perfectly, but the next ones are printed to the first specified printer (in Devices and Printers the default printer changes but the target printer remains the first one) Here is the code: </p>
  
  <pre><code>Public Sub PrintHTML(ByVal text As String, ByVal printer As String)
      Try
          LogData("Changing default printer to " &amp; printer)
          Dim wtype = Type.GetTypeFromProgID("WScript.Network")
          Dim instance = Activator.CreateInstance(wtype)
          wtype.InvokeMember("SetDefaultPrinter", System.Reflection.BindingFlags.InvokeMethod, Nothing, instance, New Object() {printer})
      Catch ex As Exception
          LogData("Changing failed...")
          LogData(ex.ToString)
      Finally
          LogData("PrintHTML Init with " &amp; printer)
          Me.wbForPrint.Navigate("about:blank")
          If Not WebBrowserReadyState.Interactive = WebBrowserReadyState.Complete Then
              Me.wbForPrint.Stop()
          End If
          Me.wbForPrint.DocumentText = text
          AddHandler (Me.wbForPrint.DocumentCompleted), AddressOf HTMLDocumentCompleted
      End Try
  
  End Sub
  </code></pre>