Dev Direct Solution Center

For more information and to buy this product...

Convert HTML to PDF using activePDF WebGrabber

 Note: This solution requires the component to be installed first.
To download the installer, click here

Introduction

The following VBScript example demonstrates activePDF WebGrabber's basic page grabbing functionality using the IE Engine.

Detail

VBScript
'Get local path as varPath arrayScr = Split(WScript.ScriptFullName, "\", -1, 1) For i = 0 to UBound(arrayScr) - 1 varPath = varPath & arrayScr(i) & "\" Next ' Define Variables ' EngineToUse (1=IE, 0=Native) varEngine = 1 ' URL format: "http://www.activepdf.com" or "file://folder/file.htm" varURL = "http://www.activepdf.com/support/knowledgebase/view.cfm?kb=10544&code=vbs" ' Timeout for various calls varTimeout = 60 ' For local machine use these defaults varIP = "127.0.0.1" varPort = "64320" ' Instantiate Objects Set WG = CreateObject("APWebGrabber.Object") Set APS = CreateObject("APServer.Object") ' Set activePDF Server properties APS.OutputDirectory varPath APS.PDFTimeout = varTimeout ' Must call before DoPrint to pass server settings to WG WG.Prt2DiskSettings = APS.ToString() ' Set WebGrabber properties WG.EngineToUse = varEngine WG.URL = varURL WG.TimeOut = varTimeout WG.PrinterTimeout = varTimeout ' Start the conversion process varReturn = WG.DoPrint(varIP, varPort) If varReturn <> 0 Then Error("DoPrint") End If ' Wait for conversion result varReturn = WG.Wait(varIP, varPort, varTimeout, "") If varReturn <> 19 Then Error("Wait") End If ' Run WG CleanUp WG.Cleanup varIP, varPort ' Clear Objects Set WG = Nothing Set APS = Nothing ' Error Handling Sub Error(Method) Msgbox "'" & Method & "' failed with a '" & varReturn & _ "'" & VBCRLF & "KB article on Return codes:" & VBCRLF & _ "http://www.activepdf.com/support/knowledgebase/viewKb.cfm?id=10033&tk=ts" Set WG = Nothing Set APS = Nothing Wscript.Quit End Sub
Visit activePDF for more information and more samples.