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 with ASP

How to take screenshot of web page with ASP - ASP Sample Code

Download ACA WebThumb ActiveX

For Windows 7/Vista/2003/XP/2000

This article shows a solution for taking screenshot of web page with ASP. To add this feature in your ASP project, you can try ACA WebThumb ActiveX - a web page to image developer SDK. It helps your general screenshot of given URLs in batch with a few fuction calls.

Guidelines: Take screenshot of web page with ASP

  1. Download ACA WebThumb ActiveX, and then install it.
  2. Click Start menu, and then select "Program -> ACASystems -> ACA WebThumb ActiveX Control -> Samples", You will find rich samples in the folder ASP.
  3. You can copy these ASP script files to your local WWW folder and then launch them.

ASP Sampe Code: Take screenshot of web page

Script file: screenshot.asp

<%
'---------------------------------------------------------------------------------------
' Script: 
'     screenshot.asp
' Remark:
'     This sample script shows how to take screenshot of web page with ASP and then
'     save as a PNG image file.
' Parameter:
'     url: the web page URL. The default value is http://en.wikipedia.org/wiki/Screenshot
' Example:
'     http://localhost/screenshot.asp
'     http://lccalhost/screenshot.asp?url=http://www.google.com
'---------------------------------------------------------------------------------------

' 1. Set the save folder and get image parameters

' [IMPORTANT NOTE]: 
' This sample saves the snapshot to the folder on the work folder of this script. 
' Please make sure the script has the WRITE permission in this folder.
' You can also set the value to other folder, for example: 
'   t_strSaveFolder = "c:/my-folder"
t_strSaveFolder = Server.MapPath("./")

' 2. Get the parameters
t_strURL = request.QueryString("url")
If ("" = t_strURL) Then
  t_strURL = "http://en.wikipedia.org/wiki/Screenshot"
End If

' 3. Create instance ACAWebThumb.ThumbMaker
err = 0
set t_xThumbMaker = server.createobject("ACAWebThumb.ThumbMaker") 
If ( err <> 0 ) then
  Response.write("Call Createobject(ACAWebThumb.ThumbMaker) Failed. Error Code: " & err & "<br>")
  Response.end()
End If

' 4. Set the URL and start snap
t_xThumbMaker.SetURL (t_strUrl)
t_iResult = t_xThumbMaker.StartSnap()
If 0 = t_iResult Then
  ' snap successful, save the image with full size.
  t_strLargeImage = t_strSaveFolder & "/screenshot-large.png"
  t_bRet1 = t_xThumbMaker.SaveImage(t_strLargeImage)
  
  ' save thumbnail (Size: 320x240)
  t_strSmallImage = t_strSaveFolder & "/screenshot-small.png"
  call t_xThumbMaker.SetThumbSize(320, 240, 0)
  t_bRet2 = t_xThumbMaker.SaveImage(t_strSmallImage)
  
  ' show the image
  If ( t_bRet1  AND t_bRet2 ) Then
    Response.Write("<b>The snapshot from "+t_strURL+"</b>:<br><br>")
    Response.Write("<a href='main-thumb.large.png'><img src='main-thumb.small.png' ><br></a>")
  else
    Response.Write("ERROR: Can't save the snapshot to file <br>")
    Response.Write("Please make sure the script has the WRITE permission in this folder.")
  End If
Else 
  Response.Write("ERROR: Snap from "+t_strURL+" failed.<br>")
End If

set t_xThumbMaker = Nothing
%>
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!