Get a rendered copy of the page as data.

 

   
Syntax
 
     

data = Doc.GetAs(path, [width], [height], [quality], [srcLeft], [srcTop], [srcWidth], [srcHeight])

 

   
Params
 
     
Name   Type   Description
path String

A dummy file path used to indicate the type of image being requested.

width Integer

The optional width of the final output image. The default is the width of the HTML page.

height Integer

The optional height of the final output image. The default is the height of the HTML page.

quality Integer

The optional quality of the final output image ranging from 0 to 100. The default is 75.

srcLeft Integer

The optional left coordinate of the source rectangle on the HTML page from which content is to be rendered. The default is 0.

srcTop Integer

The optional top coordinate of the source rectangle on the HTML page from which content is to be rendered. The default is 0.

srcWidth Integer

The optional width of the source rectangle on the HTML page from which content is to be rendered. The default is the width of the page.

srcHeight Integer

The optional height of the source rectangle on the HTML page from which content is to be rendered. The default is the height of the page.

data Array of Bytes

The rendered page as an Array of Bytes.

 

   
Notes
 
     

Normally you will want to save your rendered pages using the Save method. However sometimes you will need to obtain your pages as raw data rather than in file format. The GetAs function allows you to do this

You may wish to write your images direct to a client browser rather than going through an intermediate file. The data you obtain using GetAs can be written direct to an HTTP stream using Response.BinaryWrite. Similarly you may wish to obtain raw data for insertion into a database.

When you save the current page the image type is inferred from the dummy file path you specify. You can save as BMP, JPEG, GIF, TIFF or PNG.

The width and height of the output image default to the width and height of the page. If you specify a different width and height the contents of the page will be scaled to fit the new image size.

The quality of the output image defaults to 75. This provides a good compromise between image quality and size for JPEG output. You can override this quality using the quality parameter.

The source rectangle for the image defaults to the entire area of the HTML page. However you can choose to draw only a selected portion of the page using the srcLeft, srcTop, srcWidth and srcHeight parameters.

The GetAs method will not return until all the resources required by the page are fully loaded or the timeout expires. If the timeout expires before all the resources are fully loaded you may get an incomplete page rendered. You can exert finer control over the page load process using the Load method and the Timeout, Loaded and Loading properties.

 

   
Example
 
     

The following code illustrates how one might thumbnail a web page on the fly without saving any files. This code makes up an entire page which serves an image rather than HTML text.

<% @Language="VBScript" %>
<%
Response.Buffer = True
Response.Expires = -1000

Set page = Server.CreateObject("ABCDrawHTML.Page")
page.URL = "http://www.websupergoo.com/"
theData = page.GetAs("image.jpg", 200, 150, 30)

Response.ContentType = "image/jpeg"
Response.AddHeader "content-length", UBound(theData) - LBound(theData) + 1
Response.Addheader "content-disposition", "inline; filename=myimage.png"
Response.BinaryWrite theData
%>


page.asp