ReadUrl

The ReadUrl method builds image from content of page on website or from local html document.

ReadUrl Url,Width,Height[,Timeout][,Flags][,MinimalWaiting]

Parameters

Url
Specifies the Url or path local html file.
Width
Specifies width of imagespace area to render html document on.
Height
Specifies height of imagespace area to render html document on.
Timeout
Optional. Specifies maximal time (in seconds) of waiting for complete load of html document content. If reading html document and inline images spends less time than specified by Timeout parameter then methods returns faster (when reading is complete). Default value is 10.
bFlags
Optional. Specifies additional options. You can join them using bitwise or operation.
FlagDescription
1Removes vertical scroll bar from html page image
2Removes horizontal scroll bar from html page image
Default value is 0.
MinimalWaiting
Optional. Specifies minimal time of waiting for complete downloading the whole document content. If this parameter is specified, ShotGraph will wait this amount of time even web document already loaded. Default value is 0.
This parameter can be used for capturing webpages dynamically changing themselves in time (using some client side script etc.)

Return value

This method returns 0 if page downloaded and rendered successfully, 1 if page was not downloaded and rendered in specified amount of time. In the last case part of page can be downloaded and rendered.

Remarks

The ReadUrl method works like the ReadImage method with exception that the ReadUrl method loads image to active imagespace from specified HTML document. The HTML screenshot looks exactly as if you view that document in your Web browser.

Permission settings

Administrator can disable or enable the ReadImage method. All settings are located in the registry under the key HKEY_LOCAL_MACHINE\SOFTWARE\Mikhail\ShotGraph\Parameters
There are two DWORD values
ValueMeans
ReadUrl Bit 0 (the low ordered bit) enables reading content of websites, bit 1 enables reading of local documents. If all bits are set to 0 (or the value is absent in the registry) then the ReadUrl method is disabled. Therefore, value 1 means that only HTTP websites are allowed, value 2 means only local documents are allowed, value 3 means both websites and local documents are allowed.
ReadUrlMaxTimeout Optional value. This is the maximal timeout value in the ReadUrl method. Caller cannot set timeout value greater than this amount. Default value is 40.

You can use the following .reg file to quick set registry parameters for ReadUrl:

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Mikhail\ShotGraph\Parameters]
"ReadUrl"=dword:00000003
"ReadUrlMaxTimeout"=dword:00000028

Example 1
This .vbs example loads web page and saves screenshot as gif or Jpeg file

Set g = CreateObject("shotgraph.image")
imagetype = "jpeg"
width = 800
height = 600
url = "http://www.w3c.org"
g.CreateImage width,height,256
result = g.ReadUrl(url,width,height,15)
Select Case imagetype
Case "gif"
	g.BuildPalette 0
	g.GifImage -1,0,"c:\website.gif"
Case "jpeg"
	g.JpegImage 90,0,"c:\website.jpg"
End Select

Wscript.echo "Web screenshot has been created: " & result
Example 2
This .vbs example loads web page and makes its thumbnail. The result is shown in the top of this document.

Set g = CreateObject("shotgraph.image")
width = 800
height = 600
newwidth = 160
newheight = 120
url = "http://www.w3c.org"
g.CreateImage newwidth,newheight,8
g.InitClipboard width,height
g.SelectClipboard True
g.ReadUrl url,width,height,15
g.Stretch 0,0,newwidth,newheight,0,0,width,height,"SRCCOPY","HALFTONE"
g.SelectClipboard False

g.JpegImage 90,0,"thumb_website.jpg"

Wscript.echo "Thumbnail created"