A handy script to convert html to image

You may need to run a command line utility to convert html or url to image. Here is a handy script that converts url/html to image with our award winning htmlsnapshot product.

Save the below code into a script snapurl.vbs (Or you can find this script in htmlsnapshotdemovbscript)

set args = WScript.Arguments
num = args.Count

if num <> 2 then
   WScript.Echo “Usage: [CScript | WScript] snapurl.Vbs Url ImageFile”
   WScript.Quit 1
end if

‘demo how to convert html to image
Dim snap

‘Create the Html Snapshot Object
Set snap = CreateObject(“HTMLSNAP2.HtmlSnap.1″)
snap.SetCode “Input your license code here to remove watermark”
snap.SnapUrl args.Item(0), args.Item(1)
WScript.echo “Snap return:” & CStr(snap.GetErrorCode)

‘Free object
Set snap = Nothing

 After that, you can run on command line like below:

cscript.exe snapUrl.vbs www.google.com g.jpg
cscript.exe snapUrl.vbs file://c:1.html g.jpg