The following VBScript example demonstrates how to specify an array of URLs for conversion to PDF using activePDF WebGrabber.
This file is required:
MultipleURLs.vbs - Code detail provided below.
Click here to download this example (includes required file):
' 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
' Filename of output PDF
varOutputName = "Multiple.pdf"
' EngineToUse (1=IE, 0=Native)
varEngine = 1
' Add URLs to convert into an array
' URL format: "http://www.activepdf.com" or "file://folder/file.htm"
arrayURL = Array("http://www.activepdf.com/support/knowledgebase/view.cfm?kb=10284&code=vbs",_
"http://www.activepdf.com/support/knowledgebase/view.cfm?kb=10038",_
"http://www.activepdf.com/support/knowledgebase/view.cfm?kb=10033")
' 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.NewDocumentName varOutputName
APS.PDFTimeout = varTimeout
APS.ConcatenateToExisting = True
' Must call before DoPrint to pass server settings to WG
WG.Prt2DiskSettings = APS.ToString()
' Native Engine Properties
If varEngine = 0 Then
WG.PrintBackgroundColors = 1
WG.TopBottomMargin = 150
WG.LeftRightMargin = 150
End If
' Start Loop to convert each URL appending each conversion
' to the PDF file specified in NewDocumentName
For i = 0 To UBound(arrayURL)
' Specify the URL to convert from the array
WG.URL = arrayURL(i)
' 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
Next
' Successful Conversion
msgbox "Success!"
' 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
The information in this article is for the use of activePDF Customers and Evaluation Users Only. No part of this document may be transmitted or reproduced without the express written consent of activePDF.