.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

How to Convert the Html page to an Image file

Posted By: Deco     Posted Date: September 11, 2010    Points:2   Category :C#
I need to convert the HTML file into a jpeg image

Can anyone give me the source code for this

Requirement?

Responses
Author: Amit Mehra             
Posted Date: September 12, 2010     Points: 5   

Hi

To convert HTML or aspx page into an Image file you can use below code

private void saveURLToImage(string url)
{
if (!string.IsNullOrEmpty(url))
{
string content = "";

System.Net.WebRequest webRequest = WebRequest.Create(url);
System.Net.WebResponse webResponse = webRequest.GetResponse();
System.IO.StreamReader sr = new StreamReader(webResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("UTF-8"));
content = sr.ReadToEnd();
//save to file
byte[] b = Convert.FromBase64String(content);
System.IO.MemoryStream ms = new System.IO.MemoryStream(b);
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
img.Save(@"c:\pic.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

img.Dispose();
ms.Close();
}
}


ref http://forums.asp.net/t/1221348.aspx

Thanks,
Amit
Please "Mark As Answer " if this post help you.
Author: Deco             
Posted Date: September 12, 2010     Points: 5   

Amit,

The above coding is not converting the images i have in the html page

Can you please help me to get the image too...

Regards,
Deco
Author: jignesh             
Posted Date: September 13, 2010     Points: 5   

hey Alwyn please visit this link

http://www.codeproject.com/KB/graphics/html2image.aspx

Author: danny dog             
Posted Date: May 07, 2013     Points: 20   

my friend once mentioned this image converter, and i look it up in its site and found it can do html to many images conversion , if you haven't found a good way to do that, you can have a try. good luck.
http://www.rasteredge.com/how-to/csharp-imaging/pdf-convert-html/

Author: lily             
Posted Date: March 06, 2014     Points: 20   

in this link, you can find the source code that will help you convert html page to image in any kind of format.
http://www.rasteredge.com/how-to/asp-net-imaging/image-converting/



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend