html代码:
<html>
<head>
<title>ECP-DEMO</title>
</head>
<body style="margin:0 0 0 0;">
<table style="width:100px;height:50px; color:Red; background-color:Black;">
<tr>
<td>aaa<td>
<td>444</td>
</tr>
<tr>
<td>bbb<td>
<td>5555</td>
</tr>
<tr>
<td>ccc<td>
<td>888</td>
</tr>
</table>
</body>
</html>
c#代码
 WebBrowser webBrowser1 = new WebBrowser();
                webBrowser1.Navigate("d:\\tipDiv1.html");
                while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
                {
                    Application.DoEvents();
                }                //int scrollHeight = webBrowser1.Document.Body.ScrollRectangle.Height;
                //int scrollWidth = webBrowser1.Document.Body.ScrollRectangle.Width;                //int scrollHeight = webBrowser1.Document.Window.Size.Height;
                //int scrollWidth = webBrowser1.Document.Window.Size.Width;
                //暂时写死
                int scrollHeight =50;
                int scrollWidth 100;                webBrowser1.Height = scrollHeight;
                webBrowser1.Width = scrollWidth;
                
                webBrowser1.Dock = DockStyle.Fill;                Bitmap bm = new Bitmap(scrollWidth, scrollHeight);                webBrowser1.DrawToBitmap(bm, new Rectangle(0, 0, bm.Width, bm.Height));
                webBrowser1.Dispose();                string saveAsName;
                saveAsName = "d:\\temp\\a.bmp";                pictureBox1.Image = bm;
                Graphics draw = Graphics.FromImage(bm);
                
                draw.DrawImage(bm, 0, 0);
                      bm.Save(saveAsName, System.Drawing.Imaging.ImageFormat.Bmp);
    
                bm.Dispose();
                draw.Dispose();
现在的问题:
 webBrowser1的尺寸和网页的尺寸完全对不上 生成出来的图片 带有下拉条和横向滚动条 我不明白 webBrowser1的尺寸 到底怎么样才能跟网页的尺寸对应 其实我想生成出来的图片 就是网页table的内容 其他的都不要