WebBrowser.Print () wait until completion .. NETWORK

I am using the WebBrowser control in VB.NET and calling the Print () method. I print using a PDF printer and when Print () is called, it does not start immediately (it waits until it finishes running the code for the entire Sub or block.

I need to make sure that the file that I print is also completed and will continue the process with this file, so I would like to print on demand and get some status when the operation is completed. I tried using printDocument and handle it with no luck.

Does anyone have any ideas?

+5
source share
2 answers

PrintTemplateTeardown WebBrowser. , , , . Microsoft Internet Controls.

Private Sub Print()
    AddHandler DirectCast(WebBrowser1.ActiveXInstance, SHDocVw.WebBrowser).PrintTemplateTeardown, AddressOf PrintDone
    WebBrowser1.Print()
End Sub
Private Sub PrintDone(ByVal obj As Object)
    Trace.WriteLine("printed")
    RemoveHandler DirectCast(WebBrowser1.ActiveXInstance, SHDocVw.WebBrowser).PrintTemplateTeardown, AddressOf PrintDone
End Sub
+5

"printjobscollection" , = 0

vb.net:

    Dim intprint As Integer = Nothing

    retry2:
    intprint = GetPrintJobsCollection(printerinuse)
    If Not intprint = 0 Then
        System.Threading.Thread.Sleep(1000)
        GoTo retry2
    End If
    'do what you want to do after print completes here
+1

All Articles