Improving Performance with Page Caching and Cookie Controls in WebGrabber 2009

With the release of WebGrabber 2009 R1.1, page caching and cookie controls have been introduced to provide you with even more control over how input web pages are handled and improve overall conversion performance.
By enabling these features, elements of your web page can be stored and later used in subsequent conversions, decreasing load times and increasing conversion speed.

The CookieControl property allows you to specify how web page cookies are handled during the conversion process. If set to 1, cookie handling is enabled and WebGrabber will save cookie data for converted web pages, reducing the processing time for these pages during subsequent conversions. You can also specify the directory in which cookies are stored using the CookieDir property (default is C:\WINDOWS\activepdf\WebGrabber\cookie).

Note: Though WebGrabber automatically deletes expired cookies from the specified cookie directory, you can also manually remove all cookies using the ClearCookie method.

WebGrabber's cache functionality allows you to store entire pages (up to 50 MB) for use in subsequent conversions, decreasing load time and improving overall conversion speed. Setting the UseCachedCopy property instructs WebGrabber to save a cached copy of the specified URL to the directory set using CacheDir (default is C:\WINDOWS\activepdf\WebGrabber\cache) or load the previously cached copy if one already exists. Additionally, the PagesToCache property can be used to set a maximum number of pages to store in the cache directory. Once this number is reached, the oldest pages in the directory are deleted, enabling you to conserve disk space.

Note: Though WebGrabber automatically deletes cached pages once the PagesToCache limit is reached, you can also manually remove all cached pages using the ClearCache method.

The following example demonstrates how you can enable cookie handling and page caching, in order to streamline page conversions. 

' Get local path as varPath
arrayScr = Split(WScript.ScriptFullName, "\", -1, 1)
For i = 0 to UBound(arrayScr) -1

varPath = varPath & arrayScr(i) & "\"


' Define Variables

' Filename of output PDF
varOutputName = "WG_2009_Sample.pdf"

' URL format: "" or "file://folder/file.htm"
varURL = ""

' For local machine use these defaults
varIP = ""

varPort = "64320"

' Instantiate Objects
Set WG = CreateObject("APWebGrabber.Object")

' Enable Debugging
WG.Debug = True

' Set ActivePDF properties(previously Server properties)
WG.OutputDirectory varPath

WG.NewDocumentName varOutputName

' Specify the URL to convert

' Use Cookies
WG.CookieControl = 1

WG.CookieDir = "C:\WGCookies"

' Use Cache
WG.UseCachedCopy = 1

WG.CacheDir = "C:\WGCache"

' Start the conversion process
varReturn = WG.DoPrint(varIP, varPort)

If varReturn <> 0 Then


End If

' Wait for conversion result
varReturn = WG.Wait(varIP, varPort, varTimeout, "")

If varReturn <> 19 Then


End If

' Run WG CleanUp
WG.Cleanup varIP, varPort

' Successful Conversion
msgbox "Success!"

' Clear Objects
Set WG = Nothing

' Error Handling
Sub Error(Method)

msgbox "'" & Method & "' failed with a '" & varReturn & _

"'" & VBCRLF & "KB article on Return codes:" & VBCRLF & _


Set WG = Nothing

Set APS = Nothing


End Sub