Tuesday, 9 December 2014

Work around for WebBrowser.Print() and IE's failure to page webpage title (.NET)



I am trying to batch print XML from a .NET application and automatically create files with the names the same as the webpage title. But IE refuses to pass the of the html webpage to PFDCreator's autosave. It always ends up title as the URL. This isn't an issue when manually printing from Firefox, but visual studio uses an IE wrapper. Any work-around suggestions would be greatly appreciated...


This is my current Print Sub:



''****************************************************************************

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If ListBox1.Items.Count > 0 Then
Dim wb As New WebBrowser
For Each file In OpenFileDialog1.FileNames
wb.Navigate(file)
Do Until wb.ReadyState = WebBrowserReadyState.Complete
Application.DoEvents()
Loop
wb.Print()
Next
wb.Dispose()
End If
MsgBox("Printing Finished. " & FilesPrinted & " files printed")
End Sub

''****************************************************************************

No comments:

Post a Comment