locked
Html to image conversion RRS feed

  • Question

  • Hi all

    am new to image techniques in .net

    my requirement is to convert small peace of html to image when a button is clicked.

    can u any one worked on this one.

    please help me regarding conversion of html to image.

     

    Thanks and regards

    bhargavi.

     

    Friday, June 29, 2007 5:08 AM

Answers

  • As HTML is a descriptive document format, converting it to image would will have to be a 2 step process - Rendering the HTML, and then capturing the rendered document's pixels. Your best bet would be to have an IE control Render the HTML document for you to the screen, then get the control's device context, and copy the pixels into an image.

     

    Not a simple job, but at least the controls are available to do most of the hard work for you (i.e. rendering the HTML, and snatching an image from a window).

     

    Mick

     

    Friday, June 29, 2007 6:56 AM
  • Here is one solution to convert html to image. But it uses the third component HtmlSnapshot(including dll and demo).

     

    Some guidelines and code snippet are also included in this related article.

     

    Hope that helps!

     

     

    This response contains a reference to a third party website. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Tuesday, July 3, 2007 7:46 AM

All replies

  • As HTML is a descriptive document format, converting it to image would will have to be a 2 step process - Rendering the HTML, and then capturing the rendered document's pixels. Your best bet would be to have an IE control Render the HTML document for you to the screen, then get the control's device context, and copy the pixels into an image.

     

    Not a simple job, but at least the controls are available to do most of the hard work for you (i.e. rendering the HTML, and snatching an image from a window).

     

    Mick

     

    Friday, June 29, 2007 6:56 AM
  • Here is one solution to convert html to image. But it uses the third component HtmlSnapshot(including dll and demo).

     

    Some guidelines and code snippet are also included in this related article.

     

    Hope that helps!

     

     

    This response contains a reference to a third party website. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Tuesday, July 3, 2007 7:46 AM
  • Additionally, here are two references which have clean solutions despite of C++ code.

     

    Rendering an IHTMLElement to an Image File Using GDI+

     

    Capture an HTML document as an image

    Tuesday, July 3, 2007 8:24 AM
  • hi

    thanks a lot

    will try it , hope it surely helps for me.

    once again thanks a lot

    Friday, July 6, 2007 3:44 AM
  • Hi, you can also try this .NET Word component which has a really simple file conversion API.

    Here is a sample C# code for converting HTML to PNG in button click event:

    private void button1_Click(object sender, EventArgs e)
    {
        DocumentModel.Load("Sample.html", LoadOptions.HtmlDefault).Save("Sample.png", SaveOptions.ImageDefault);
    }

    Monday, July 8, 2013 11:20 AM