Erzeugt einen Screenshot von einer beliebigen Webseite.
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
namespace ScreenshotMaker
{
public static class ScreenshotMaker
{
public static void MakeScreenshotFromUrl(string url)
{
WebBrowser wb = new WebBrowser();
wb.ScrollBarsEnabled = false;
wb.ScriptErrorsSuppressed = true;
wb.Navigate(url);
while (wb.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); }
wb.Width = wb.Document.Body.ScrollRectangle.Width;
wb.Height = wb.Document.Body.ScrollRectangle.Height;
Bitmap bitmap = new Bitmap(wb.Width, wb.Height);
wb.DrawToBitmap(bitmap, new Rectangle(0, 0, wb.Width, wb.Height));
wb.Dispose();
bitmap.Save(@"C:\screenshot.jpg", ImageFormat.Jpeg);
}
}
}
2 Kommentare zum Snippet