how to draw a part of the page to image RRS feed

  • Question

  • User-1034485156 posted


    i want to draw a part of the page like panel or table  or whatever to image

    how to convert it to stream to save it to image?


    thanks in advance.


    Thursday, January 24, 2008 10:05 AM

All replies

  • User1038007851 posted

    There are basically two options:

    1) Capture the entire html page after it's rendered and then crop out what you're looking for

    2) Render the html directly to an image, and crop out what you're looking for

    There isn't a way to get just a particular html element to render directly to an image.  You'll have to pick either option and then manually remove what you want, or calculate where the piece you want is and remove it through GDI.

    If you want to go the route of capturing just the image, you can use one of the many tools that are made specifically for doing so ( html2jpg is one ). There used to be a few free ones laying around, but i couldn't find them in a quick search.

     If you want to go the route of doing the rendering yourself, you can use the shdocvw dll and render into your own graphic context.  It's pretty complex stuff, but if you're determined enough you can get something functional that runs in the managed world.

    Here's a few links for option #2 from codeproject:

    C# capturing of IE using shdocvw: http://www.codeproject.com/KB/graphics/IECapture.aspx

    Native C++ capturing of IE using shdocvw: http://www.codeproject.com/KB/IP/htmlimagecapture.aspx

    Hope this helps!


    Thursday, January 24, 2008 10:37 AM
  • User-1034485156 posted

    thanks for reply

     you mention a tool called html2jpg and this is a program how can i use it on the server that i will upload the site to? do you mean i will execute it?

    there was a solution for that and it was to capture the byte array of the element and save it as image and this on the server side control event i don't remember what the event was

    any way if any one knows what i mean i need help


    thanks in advance.


    Thursday, January 24, 2008 12:32 PM
  • User-1034485156 posted

    any help 

    Friday, January 25, 2008 1:36 PM
  • User-1034485156 posted

    im asking if there any asp.net third party component that convert server controls to image

    Sunday, January 27, 2008 6:59 AM
  • User-417355750 posted

    @seco I am in the same situation and trying to achieve the same.Please share the code .



    Friday, October 1, 2010 10:36 AM