WebGrabber WBE 2010

Basic Conversion

Example code is for an older version of WebGrabber, newer code is available.
' Copyright (c) 2019 ActivePDF, Inc.
' ActivePDF WebGrabber WBE 2010
' Example generated 10/20/19 

Imports System

' Make sure to add the ActivePDF product .NET DLL(s) to your application.
' .NET DLL(s) are typically found in the products 'bin' folder.

Public Class Examples
  Sub Example()
    Dim strPath As String, intDoPrint As Integer

    strPath = AppDomain.CurrentDomain.BaseDirectory

    ' Instantiate Object
    Dim oWG As APWebGrbNET.APWebGrabber = New APWebGrbNET.APWebGrabber()
    
    ' Enable extra logging - c:\windows\activepdf\logs
    ' Logging should be disabled during production
    oWG.Debug = true
    
    ' Fast web view
    oWG.LinearizeDocument = true
    
    ' Time to wait for conversion to complete (in seconds)
    oWG.Timeout = 30
    
    ' Margins (Top, Bottom, Left, Right) 1.0 = 1"
    oWG.SetMargins(0.75, 0.75, 0.75, 0.75)
    
    ' 0 = Portrait, 1 = Landscape
    oWG.Orientation = 0
    
    ' Convert HTML fields to PDF fields
    oWG.PreserveButtons = false
    oWG.PreserveCheckBoxes = false
    oWG.PreserveDropDowns = false
    oWG.PreserveRadioButtons = false
    oWG.PreserveTextBoxes = false
    
    ' Convert links
    oWG.PreserveLinks = true
    
    
    ' Enable flash conversion
    oWG.EmbedFlash = true
    
    ' PDF output location and filename
    oWG.OutputDirectory = strPath
    oWG.NewDocumentName = "basic.pdf"
    
    ' HTML to convert
    ' Examples:
    ' http://domain.com/path/file.aspx
    ' c:\folder\file.html
    oWG.URL = "http://examples.activepdf.com/system/files/49/original/wg.html"
    
    ' Perform the HTML to PDF conversion
    intDoPrint = oWG.DoPrint("127.0.0.1", 54545)
    If intDoPrint <> 0 Then
      ErrorHandler("DoPrint", intDoPrint)
    End If
    
    ' Cleans up all internal string variables used during conversion
    ' By default variables are deleted 3 minutes after the conversion
    oWG.CleanUp("127.0.0.1", 54545)
    
    ' Release Object
    oWG = Nothing
    
    ' Process Complete
    WriteResults("Done!")
  End Sub
  
  ' Error Handling
  ' Error messages written to debug output
  Sub ErrorHandler(ByVal strMethod, ByVal RtnCode)
    WriteResults(strMethod + " error:  " + rtnCode.ToString())
  End Sub
  
  ' Write output data
  Sub WriteResults(content As String)
    ' Choose where to write out results
  
    ' Debug output
    'System.Diagnostics.Debug.WriteLine("ActivePDF: * " + content)
  
    ' Console
    Console.WriteLine(content)
  
    ' Log file
    'Using tw = New System.IO.StreamWriter(AppDomain.CurrentDomain.BaseDirectory & "application.log", True)
    '   tw.WriteLine("[" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + "]: => " + content)
    'End Using
  End Sub
End Class

Copyright © 2019 ActivePDF, Inc