For a while I have been thinking about how to capture the output of IE into a Bitmap or other image format. The attempts that I have done normally center around hosting an IE control on a WinForm and then render the page inside the control and then capture the output. This however seems to be pretty hairy, I could never get it to work after the initial screen capture.
It just so happens that the WindowsLiveWriter API has an object called HtmlScreenCapture.
HtmlScreenCapture is really simle to use. The code below captures the webpage and renders it to a picture box that I have on my WinForm.
Uri uri = new Uri("http://www.kinlan.co.uk/");
WindowsLive.Writer.Api.HtmlScreenCapture hsc = new HtmlScreenCapture(uri, 800);
pictureBox1.Image = hsc.CaptureHtml(1000);
You can import the WindowsLiveWriter API into your project by finding the WindowsLive.Writer.Api.dll file in the WindowsLiveWriter install directory.
Obviously, WindowsLiveWriter is still beta as of Jan 2007, so they may remove this API.
Anyway it is really simple to use, so anyone could create an imaging service in minutes, much like http://www.websnapr.com/ can.
Comments: [Add New]
I cant get it to work as a .NET generic handler!
Have you tested it in a we application or are you just assuming it will work in a web app?
Hi,
When I was thinking about how I would do this, i didn't want to put it in a HTTP Handler to handle on WebRequests comming into my server.
Rather, I was going to create a Windows Service that read a database of screen shots that it had to generate, and put it in a place where the webserver can get to it.
Kind Regards,
Paul Kinlan
Anyone figure out why this does not work in the context of IIS 7 + vista? On know the security model is different but I would really like to use this API. Specfically I would really like to use the constructor that takes in the HTML directly instead of the Uri but this always generates and exception.
-Will
