try abc

try abc

  • 1.4k
  • 306
  • 487.3k

Problem in taking screenshot of webPages

Jun 4 2008 9:16 AM
Hello,

I want screenshot of website by passing url. I used the DrawtoBitmap method of webbrowser but it is not working properly. It gives empty images. I want screenshot of  websites which i passed in loop.

Code ::

arrayList arrURL;
bool flagSC = true;

 for(int i=0l i< url.length;i++)
{
    if (flagSC == true)
    {
        webbrowser1.navigate(arrURL[i].ToString());

        while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
        {
                 Application.DoEvents();
        }
    }
    else
    {
          i -= 1;
     }
  

 private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {        
                flagSC = false;
                Bitmap bitmap = new Bitmap(webBrowser1.Bounds.Width, webBrowser1.Bounds.Height);
                webBrowser1.DrawToBitmap(bitmap, webBrowser1.Bounds);
                bitmap = (Bitmap)bitmap.GetThumbnailImage(175, 128, null, IntPtr.Zero);
                bitmap.Save(filePath);
                flagSC = true;
                bitmap.Dispose();             
        }
}

The above code gives blank images.

Thanks in advance.