We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
开发者_开发百科Closed 4 years ago.
Improve this questionIs 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.
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
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
I use WebShot's C# interface and the System.Graphics API to generate thumbnails.
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.
精彩评论