Provide state-of-the-art image capture, screen capture, video capture and audio capture software
Home     Download     Purchase     Support     Contact     View my shopping cart
You are here: ACASystems » ACA WebThumb ActiveX Control » FAQ » Take screenshot of web page in C#

How to take screenshot of web page in C# - C# Sample Code(4)

Download ACA WebThumb ActiveX

For Windows 7/Vista/2003/XP/2000

Sometimes, we want to take screenshot of web page in C# and then save as image file or output to the client's browser. To add this feature in your C# project, you can try ACA WebThumb ActiveX - a web page to image developer SDK. It helps your capture the full length web page screenshots of given URLs in batch, general thumbnial image preview of given URLs with a few function calls. In this tutorial we will see how we can take screenshot of web page in C# script codes.

Guidelines: Take screenshot of web page in C#

  1. Download ACA WebThumb ActiveX, and then install it. If you have installed it on your computer, you can ignored this step.
  2. Click Start menu, and then select "Program -> ACASystems -> ACA WebThumb ActiveX Control -> Samples", You will find a C# demo project in the folder c#.
  3. You can open this C# demo project with VS2003, VS2005 or VS2008, build and run it.

C# Sampe Code: Take screenshot of web page

This C-sharp sample script shows how to take screenshot from http://en.wikipedia.org/wiki/Screenshot and then saves as .JPG format.

// C# - Take screenshot of web page

// Specify the image filename.
// [IMPORTANT NOTE]: 
// This sample saves the screenshot image to the folder on the work dir of this script. 
// Please make sure the script has the WRITE permission in this folder.
// You can also set the value to other folder by yourself, for example: 
//   string t_strImageFolder = "c:/tmp";
string t_strImageFolder = Server.MapPath("./");           
string t_strFullImageFile = t_strImageFolder + "\\" + "wiki-fullsize.jpg";
string t_strSmallImageFile = t_strImageFolder + "\\" + "wiki-thumbnail.jpg";

// Create ActiveX object
ThumbMakerClass t_xWebSnapor = new ACAWebThumbLib.ThumbMakerClass();

// Start capture web page from http://en.wikipedia.org/wiki/Screenshot
t_xWebSnapor.SetURL("http://en.wikipedia.org/wiki/Screenshot");
t_xWebSnapor.StartSnap();

// Save the screenshot of web page in c#, image size: full size
t_xWebSnapor.SaveImage(t_strFullImageFile);

// Save the screenshot of web page in c#, image size: 320x240
t_xWebSnapor.SetThumbSize(320, 240, 0);
t_xWebSnapor.SaveImage(t_strSmallImageFile);

// Show the image
pictureBox_small.Image = Image.FromFile(t_strSmallImageFile);
pictureBox_full.Image = Image.FromFile(t_strFullImageFile);
Download ACA WebThumb ActiveX

For Windows 7/Vista/2003/XP/2000

Other resource about taking sceenshot of web page in C#:


Get discount alerts, new product information and technical articles:
Name:
Email:
* Get 10% off your first order by joining our mailing list!
* You may safely unsubscribe at any time!