How to capture web page screenshot in asp.net using c#
This article presents a Asp.net using C# routine for capturing an entire web page as an image.
using System.Windows.Forms; ////Include for taking ScreenDatails
protected void btn_SaveScreensShot_Click(object sender, EventArgs e)
Bitmap bitmap = new Bitmap
Graphics graphics = Graphics.FromImage(bitmap as System.Drawing.Image);
graphics.CopyFromScreen(25, 25, 25, 25, bitmap.Size);
First you have to add reference of the dll.
- Right click the project name
- Add reference -> .net tab and then choose system.windows.forms namespace then press ok button.
- In .aspx code behind file you have to import the System.Windows.Forms namespace and that’s it.
By customizing parameters used in CopyFromScreen() function, you can figure out how to capture the small portion of the screen, if required. Create a folder and give folder path in c# code just like above i have given. You can customize the code as well and give the dynamic name of bitmap file every time it is generated.