|
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub buttonCapture_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonCapture.Click
WebBrowser1.Navigate(textWebURL.Text)
buttonCapture.Enabled = False
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
GetImage()
End Sub
Private Sub GetImage()
If WebBrowser1.Document Is Nothing Then
Return
End If
Try
Dim scrollWidth As Integer
Dim scrollHeight As Integer
scrollHeight = WebBrowser1.Document.Body.ScrollRectangle.Height
scrollWidth = WebBrowser1.Document.Body.ScrollRectangle.Width
WebBrowser1.Size = New Size(scrollWidth, scrollHeight)
Dim bm As New Bitmap(scrollWidth, scrollHeight)
WebBrowser1.DrawToBitmap(bm, New Rectangle(0, 0, bm.Width, bm.Height))
Dim SaveAsName As String
SaveAsName = Regex.Replace(textWebURL.Text, "(\\|\/|\:|\*|\?|\""|\<|\>|\|)?", "")
bm.Save(SaveAsName & ".png", System.Drawing.Imaging.ImageFormat.Png)
bm.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
'
End Try
buttonCapture.Enabled = True
End Sub
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here