ActivePDF
Shopping Cart My Account Help Contact Us
Request a Call
Search
Products Solutions Support Downloads Corporate
Submit an Issue
Knowledge Base
Server Product Support
Examples & How-Tos
Support Options
Support Policies
Annual Subscription
Extensions
Documentation
Resource Links
   
 
 
 
 

HomeSupportKnowledge Base
 
activePDF KB #10284 - Grabbing multiple URLs for Conversion
activePDF KB #10284 - Grabbing multiple URLs for Conversion
Information: Example Printer Version | Return to Search
Grabbing multiple URLs for Conversion
 
Product Version Code Samples    
WebGrabber
3.5.2
VBS
ASP
CF
 
Description
 
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()

' Set WebGrabber properties
WG.EngineToUse = varEngine
WG.TimeOut = varTimeout
WG.PrinterTimeout = varTimeout

' 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
 
Keywords
 
webgrabber, wg, multiple, url, urls, convert, pdf, make, generate, array, grab, grabber, more, than, one, extra, two, three, four, five, collection, asp, cfm, cf, coldfusion, cold, fusion, VBS, VBScript, vb, script, example
 
Last Updated 2007-07-24 Printer Version | Return to Search
 
Knowledge Base Article Feedback*
*KB article feedback ONLY (submit support issues here)
Quality of this article?
  Poor Excellent 
1 2 3 4 5 6 7 8 9 10
Is this article helpful? Yes       No       Maybe
Comments (Optional)
Email Address (Optional)
Please enter the word "PDF"
(without quotes)
 
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.

Copyright © 2005, activePDF, Inc. All Rights Reserved
2003 activePDF Site Map Feedback Privacy Policy Legal