Download ACA WebThumb ActiveX |
For Windows 7/Vista/2003/XP/2000
If you are a C# developer, you may want to take snapshot from HTML, and then save as an image file or directly output to client's browser. To add this feature in your c# project, ACA WebThumb ActiveX is your best choice. ACA WebThumb ActiveX is a developer SDK that based ActiveX technology. With a few function calls in your C# project, it takes the snapshot from HTML page and then save as JPG, GIF, PNG, BMP, TIFF, WMF and EMF image. In this tutorial we will see how we can take snapshot from HTML in C# script codes.
This C-sharp sample script shows how to take screenshot from http://en.wikipedia.org/wiki/Snapshot and then saves as a PNG image file.
// C# - Take screenshot from HTML 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 + "\\" + "snapshot-fullsize.png"; string t_strSmallImageFile = t_strImageFolder + "\\" + "snapshot-thumbnail.png"; // Create ActiveX object ThumbMakerClass t_xSnapshot = new ACAWebThumbLib.ThumbMakerClass(); // Start capture web page from http://en.wikipedia.org/wiki/Snapshot t_xSnapshot.SetURL("http://en.wikipedia.org/wiki/Snapshot"); t_xSnapshot.StartSnap(); // Save the screenshot to file, image size: full size t_xSnapshot.SaveImage(t_strFullImageFile); // Save the screenshot to file, image size: 320x240 t_xSnapshot.SetThumbSize(320, 240, 0); t_xSnapshot.SaveImage(t_strSmallImageFile); // Show the image pictureBox_small.Image = Image.FromFile(t_strSmallImageFile); pictureBox_full.Image = Image.FromFile(t_strFullImageFile);
The above sample shows how to take snapshot from fullsize HTML page in your C# project. You can also use ACA WebThumb ActiveX to take snapshot from part of HTML page. To add this feature, you should call GetThumbWidth() and GetThumbHeight() to get the size of whole page, and then call SetClipRect() to set the clip rectangle to the image. This sample script shows how to take a snapshot of a long HTML and break it up into multiple images.
// C# - Take screenshot from part of HTML 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_strSnapshotPart1 = t_strImageFolder + "\\" + "snapshot-part1.png"; string t_strSnapshotPart2 = t_strImageFolder + "\\" + "snapshot-part2.png"; // Create ActiveX object ThumbMakerClass t_xSnapshot = new ACAWebThumbLib.ThumbMakerClass(); // Start capture web page from http://en.wikipedia.org/wiki/Snapshot t_xSnapshot.SetURL("http://en.wikipedia.org/wiki/Snapshot"); t_xSnapshot.StartSnap(); // Get the full size of image long t_lWholeWidth = t_xSnapshot.GetThumbWidth(); long t_lWholeHeight = t_xSnapshot.GetThumbHeight(); long t_lPartHeight = t_lWholeHeight / 2; // Save the part 1 of the screenshot to image t_xSnapshot.SetClipRect(0, 0, t_lWholeWidth, t_lPartHeight); t_xSnapshot.SaveImage(t_strSnapshotPart1); // Save the part 2 of the screenshot to image t_xSnapshot.SetClipRect(0, t_lPartHeight, t_lWholeWidth, t_lPartHeight); t_xSnapshot.SaveImage(t_strSnapshotPart2);
Download ACA WebThumb ActiveX |
For Windows 7/Vista/2003/XP/2000