views:

52

answers:

3

I am working on an app that will be able to pull an image of rendered HTML from a specific browser. I would like the user to be able to select a specific browser to render an HTML file in, and capture the rendered output in an image file. I also want to capture the entire HTML render at once, not simply what is visible in the browser at the time.

I am starting with IE8, and I'm not sure where to begin to get the actual rendered output. I can easily open the file in that browser with Process.Start(), but I don't know how to return the rendered output. I have looked a little bit at sinking events, but I don't understand how that works or if that's the right way to go. I would just like some direction, and perhaps some resources to send me on the right path.

A: 

Why are you creating this? There are existing services that do the exact same thing, like http://browsershots.org...

Koen
I'm aware of probably about a dozen web- or desktop-based applications that provide this service, but I have a qualm with every one of them (although I primarily use BrowserShots) and I'd like to take a crack at developing one on my own.
Geo Ego
I agree, and say "go for it."
Swingline Rage
A: 

If you are willing to depend on being able to scrape the image from the user's screen (and running on the same PC, of course); you should be able to do this by finding the browser windows bounding rectangle. Then use Graphics.CopyFromScreen to copy the pixels as displayed on the screen.

I made a simple example in my answer here, which shows you how you can take a screenshot of the user's screen. Should be easy for you to modify to your needs.

driis
I would actually like to capture the rendering of the entire HTML, not just what is visible in the browser at the time of render. I have edited my question to elaborate on this point.
Geo Ego
A: 

Edited. I thought you were trying to capture a rendered image in the browser, like a PNG, GIF, etc.

If you want to capture the HTML output as an image, I'd use the WebBrowser control's DrawToBitmap method... though it isn't 100% reliable. And obviously for open-source browsers (Webkit, etc.) this gets a lot easier.

Swingline Rage