可以对已知id的元素进行截图。
WebBrowser wb_main = new WebBrowser();
string myid="";
private void getPic(string url,string drawid)
{
myid=drawid;
wb_main = new WebBrowser();
wb_main.DocumentCompleted += Wb_main_DocumentCompleted;
string url = "yourURL";
wb_main.Navigate(url);
}
private void Wb_main_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
drawPic(myid);
}
private int drawPic(string eleID)
{
HtmlElement ht = wb_main.Document.GetElementById(eleID);
if(ht==null)
return 1;
//将元素移到最顶层,靠左靠上
ht.Style = "position: absolute; z-index: 9999; top: 0px; left: 0px";
var b = new Bitmap(ht.ClientRectangle.Width, ht.ClientRectangle.Height);
wb_main.Width = ht.ClientRectangle.Width * 2;
wb_main.Height = ht.ClientRectangle.Height * 2;
wb_main.DrawToBitmap(b, new Rectangle(new Point(),ht.ClientRectangle.Size));
pictureBox1.Image = b; //显示到pictureBox1
return 0;
}


