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.

Keith Adler
  • 20,880
  • 28
  • 119
  • 189

4 Answers4

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

Adam Neal
  • 2,147
  • 7
  • 24
  • 39
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

daniels
  • 18,416
  • 31
  • 103
  • 173
  • 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. – Kennet Belenky Mar 15 '10 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.