Search code examples
c#asp.nethtmlimageimage-generation

Converting aspx page to image file


I have c# dynamic aspx page after new property add I create for record brochure

http://veneristurkey.com/admin/Brochure.aspx?Admin=PropertiesBrochureA4&id=36

but I want to this convert image file I am searching on internet but all with webbrowser and windows forms. I need on page load show not css type also image file. jpg, png or tiff how i can do this. i need to see sample code..

saving aspx page into an image 2


Solution

  • As I mentioned in my comment, your best bet is to opt for attempting to render HTML to an image.

    Here is the link for a library that will allow your to render html to an image:

    http://htmlrenderer.codeplex.com/

    Here is code that does exactly what you're asking:

    http://amoghnatu.wordpress.com/2013/05/13/converting-html-text-to-image-using-c/

    Now all you have left is to get the html, since I'm assuming you don't want this to render to the browser prior to generating this image - you should look into grabbing the rendered html from the aspx page on the server prior to returning it, and then just return the image. To render a page:

    https://stackoverflow.com/a/647866/1017882

    Sorted.