Making WebPage Screenshot | .Net

Making WebPage Screenshot | .Net

Added by Nasir Mahmood updated on Friday, November 17, 2017


Many times we want to capture web page as picture. One possible solution is using print screen while viewing page, problem with this solution we can not capture whole page.

This is a small snippet which will capture whole page as a picture and save it to our desired path on disk.


Just copy and paste following code where you want to use.

private void WebPageSnapshot(string url, string outfile)
    using (WebBrowser browser = new WebBrowser())
        browser.ScrollBarsEnabled = false;
        browser.Size = Screen.PrimaryScreen.Bounds.Size;
        browser.ScriptErrorsSuppressed = true;                
        browser.Navigate(new Uri(url));
        while (browser.Document == null || browser.Document.Body == null)
        Rectangle pageRect = browser.Document.Body.ScrollRectangle;
        browser.Height = pageRect.Height;
        using (Bitmap bmp = new Bitmap(pageRect.Width, pageRect.Height))
          browser.DrawToBitmap(bmp, new Rectangle(0, 0, pageRect.Width, pageRect.Height));
          bmp.Save(outfile, ImageFormat.Png);


Just call above function with required parameters, where url is web page path and outfile is picture path.

WebPageSnapshot("", "c:\\snapshot.png");				


32 Tutorials
27 Snippets
6 Products


Contact Us

Contact us

Stay Connected