积极答复者
带iframe的网页如何用WebBrowser.DrawToBitmap来截图

问题
答案
-
main.html
<html> <body> <iframe src="demo_iframe.htm" width="200" height="200"></iframe> <p>Some older browsers don't support iframes.</p> <p>If they don't, the iframe will not be visible.</p> </body> </html>
demo_iframe.htm:
sdffgsdgsdf
Bitmap bitmap = new Bitmap(webBrowser1.Width, webBrowser1.Height); this.webBrowser1.DrawToBitmap(bitmap, new Rectangle(new Point(), webBrowser1.Size)); bitmap.Save(@"C:\Users\test\Desktop\a.bmp");
这就是我的测试代码和结果:
你说你抓到的是空白,我建议你删掉或者注释掉那些对此功能没逻辑关联的代码行,包括你的html页面代码,用最精简的代码和页面做测试。
或者你可以提供你的测试项目包和html文件。
Mike [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 Mike Dos ZhangModerator 2011年8月28日 7:06
全部回复
-
main.html
<html> <body> <iframe src="demo_iframe.htm" width="200" height="200"></iframe> <p>Some older browsers don't support iframes.</p> <p>If they don't, the iframe will not be visible.</p> </body> </html>
demo_iframe.htm:
sdffgsdgsdf
Bitmap bitmap = new Bitmap(webBrowser1.Width, webBrowser1.Height); this.webBrowser1.DrawToBitmap(bitmap, new Rectangle(new Point(), webBrowser1.Size)); bitmap.Save(@"C:\Users\test\Desktop\a.bmp");
这就是我的测试代码和结果:
你说你抓到的是空白,我建议你删掉或者注释掉那些对此功能没逻辑关联的代码行,包括你的html页面代码,用最精简的代码和页面做测试。
或者你可以提供你的测试项目包和html文件。
Mike [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 Mike Dos ZhangModerator 2011年8月28日 7:06
-
你好,请问你的问题解决了吗?
Mike [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.