How to convert *.aspx (HTML) page to Image format
Posted
by Swapnil Fegade
on Stack Overflow
See other posts from Stack Overflow
or by Swapnil Fegade
Published on 2010-06-10T08:18:10Z
Indexed on
2010/06/10
8:22 UTC
Read the original article
Hit count: 382
ASP.NET
I want to convert *.aspx (HTML) page's (User Interface) to Image such as JPEG. I am using below code for that
Protected Sub btnGet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGet.Click saveURLToImage("http://google.co.in") End Sub
Private Sub saveURLToImage(ByVal url As String) If Not String.IsNullOrEmpty(url) Then Dim content As String = ""
Dim webRequest__1 As System.Net.WebRequest = WebRequest.Create(url)
Dim webResponse As System.Net.WebResponse = webRequest__1.GetResponse()
Dim sr As System.IO.StreamReader = New StreamReader(webResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("UTF-8"))
content = sr.ReadToEnd()
'save to file
Dim b As Byte() = Convert.FromBase64String(content)
Dim ms As New System.IO.MemoryStream(b, 0, b.Length)
Dim img As System.Drawing.Image = System.Drawing.Image.FromStream(ms)
img.Save("c:\pic.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
img.Dispose()
ms.Close()
End If
End Sub
But I am getting Error as "Invalid character in a Base-64 string" at line Dim b As Byte() = Convert.FromBase64String(content)
© Stack Overflow or respective owner