7

Is there an API that can be used to generate thumbnails of a webpage in C#? I don't want to use third-party websites as I'd rather render them myself.

4 Answers 4

4

There's a program on CodeProject that might fit the bill...it's a "console" app (really a hidden WinForms app) using the WebBrowser control.

I played around with it a while back and it works pretty well

1

Here's an example of how to do it using GTK and Geko(Firefox) engine: http://tirania.org/blog/archive/2004/Jun-14.html

You should be able to do the same using Internet Explorer and WindowsForms if you prefer that.

LE: You do need to use an existing rendering engine like(Firefox's Geko, or Webkit, or Internet Explorer) instead of a html parser as this will allow you to capture the page as it is, with CSS, Flash, Java, etc

1
  • Re: Winforms and IE, It's been a long time since I've tried it (so they might've changed things) but it used to be you couldn't render a browser control to a bitmap. Mar 15, 2010 at 21:03
1

I use WebShot's C# interface and the System.Graphics API to generate thumbnails.

1

For a quick-and-dirty approach, you can instantiate an IE browser control and call the DrawToBitmap method. HOWEVER, this method is not strictly intended for public consumption. But it's accessible, and it does work. I wouldn't use it in production though.

Not the answer you're looking for? Browse other questions tagged or ask your own question.