如何在网页中拍摄全高的屏幕截图 [英] how to take screen shot of full height in web page

查看:75
本文介绍了如何在网页中拍摄全高的屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码如下



protected void btnCapture_Click(object sender,EventArgs e)

{



位图位图=新位图

(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width,System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height) ;



图形图形= Graphics.FromImage(位图为System.Drawing.Image);

graphics.CopyFromScreen(0,0,0) ,0,bitmap.Size);



bitmap.Save(E:/ScreenShot.bmp,ImageFormat.Bmp);

} $ / $




当我运行上面的代码并单击捕获按钮时,整个default.aspx页面都没有显示。



运行模式如下



SNO textbox1

名称textbox2

年龄文本框3

ID textbox4

DOB textbox5

地址textbox6

放置textbxo7

State Dropdownlist1

Pincode textbox8

移动文本框9

父姓名文本框10

母亲姓名文本框11

永久地址文本框12



但是当我在E文件夹中拍摄屏幕时,它保存如下



SNO textbox1

名称textbox2

年龄textbox3

ID textbox4

DOB textbox5

地址textbox6

放置textbxo7

州下拉列表1



剩下的三个如下

Pincode textbox8

移动文本框

父亲姓名文本框10

母亲姓名文本框11

永久地址文本框12





以上三个没有显示在E文件夹中,整个屏幕都没有显示。



从上面的代码中我犯了什么错误请帮助我。

解决方案

你不能在C#中截取网页的截图:它在服务器,而不是客户端。这意味着主屏幕是Web服务器屏幕而不是客户端浏览器。它可能会像你想要的那样开发,因为两台计算机都是同一台PC,但是当它们相距数千英里时,它在生产中没有任何用处!



您需要查看使用Javascript: Google [ ^

My code as follows

protected void btnCapture_Click(object sender, EventArgs e)
{

Bitmap bitmap = new Bitmap
(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);

Graphics graphics = Graphics.FromImage(bitmap as System.Drawing.Image);
graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);

bitmap.Save("E:/ScreenShot.bmp",ImageFormat.Bmp);
}


When i run the above code and click the capture button the whole default.aspx page is not displaying.

Im run mode as follows

SNO textbox1
Name textbox2
Age textbox3
ID textbox4
DOB textbox5
Address textbox6
Place textbxo7
State Dropdownlist1
Pincode textbox8
Mobile textbox9
Father Name textbox10
Mother Name textbox11
Permanent Address textbox12

But when i take screen shot in E folder it save as follows

SNO textbox1
Name textbox2
Age textbox3
ID textbox4
DOB textbox5
Address textbox6
Place textbxo7
State Dropdownlist1

The remaining three as follows
Pincode textbox8
Mobile textbox9
Father Name textbox10
Mother Name textbox11
Permanent Address textbox12


The above three is not displaying in E folder the whole screen is not displaying.

From my above code what is the mistake i made please help me.

解决方案

You can't take a screenshot of the web page in C#: it runs on the server, not the client. That means that the Primary Screen is the web server screen not the client browser. It may do something like what you want in development because both computers are the same PC, but it will do nothing useful in production when the are separated by thousands of miles!

You will need to look at using Javascript for this:
Google[^]


这篇关于如何在网页中拍摄全高的屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆