Use the COM Implementation of the API

The COM implementation of HTML Export is only applicable to Win32 environments. It is supported in both out-of-process (htmserv.exe) and in-process (htmserv.dll) versions. Programming with either interface is identical. The out-of-process version provides a more robust HTML conversion, but at the expense of making out-of-process calls. To use either version of the COM implementation, you must register the COM component. Both components support self-registration and self-unregistration. You can only register one COM component.

To use the COM Automation Server

  1. Register the COM server by using one of the following methods:

  2. Confirm the following entry is in the Windows registry:

    \\HKEY_CLASS_ROOT\VerityHtmServ.Application
  3. Create an instance of the COM object. See the comsamp sample for an example.

  4. Specify the source file by using the pszInputFile property.

  5. Specify the location of the HTML Export libraries by using the pszKeyViewDir property.

  6. Use the properties and methods described in COM Interface Methods and Events and COM Interface Properties.

Sample Implementation

The following code, which is found in the sample Visual Basic program named comsamp, demonstrates how to use the properties, methods, and events of the ActiveX Controls from within Visual Basic.

Define the htmserv Object

The sample code will not function unless you first define the htmserv object in Visual Basic.

To define the object for Visual Basic 6

  1. Select References... from the Project menu.

  2. Search available references for "HTML Export COM Server Library," and select it.

  3. If the HTML Export COM Server Library is unavailable, follow the registering instructions in Use the COM Implementation of the API.

Sample Code

  1. Declare the variable MyRef as an instance of htmserv (the HTML Export COM server):

    Dim WithEvents MyRef As htmserv
  2. Specify the source file by setting the input file property pszInputFile:

    Private Sub Convert_Click()
    MyRef.pszInputFile = File1.Path & "\" & File1.FileName
  3. Define the GetSummaryInfo method and metadata properties:

    Dim nTotal As Long
    Dim nValid As Long
    Dim nType As Long
    Dim nVal As Long
    Dim szVal As String
    Dim szUserVal As String
    ...
    On Error GoTo Handler
    Call MyRef.GetSummaryInfo(3, nTotal, nValid, nType, nVal, szVal, szUserVal)
    MsgBox szUserVal & " = " & szVal
    
  4. Call the ConvertFileToFile method:

    Convert:
       nRet = MyRef.ConvertFileToFile("c:\temp\temp.htm")
       WebBrowser1.Navigate ("c:\temp\temp.htm")
       Exit Sub
  5. The comsamp sample program specifies the default directory for source files as the C:\Program Files\Autonomy\KeyviewExportSDK\testdocs directory, and the directory in which binaries are stored as the C:\Program Files\Autonomy\KeyviewExportSDK\>OS\bin directory, where OS is the name of the operating system. To change these directories to match your installation, set the Path property to the location of the testdocs directory, and set the pszKeyViewDir property to the location of the HTML Export binary files:

    Private Sub Form_Load()
       Set MyRef = New htmserv
       Dir1.Path = "C:\myinstall\testdocs"
       MyRef.pszKeyViewDir = "C:\myinstall\bin"
    End Sub
    
  6. Implement the Continue event that is called by HTML Export:

    Private Function MyRef_Continue(ByVal PercentDone As Long) As Long
       ProgressBar1.Value = PercentDone
       MyRef_Continue = True
       ProgressBar1.Refresh
    End Function

    Refer to Continue for more information.

  7. Implement the UserCallback event:

    Private Function MyRef_UserCallback(ByVal szUserString As String) As String
       MsgBox (szUserString)
       MyRef_UserCallback = "Output this text to HTML"
    End Function

    See UserCallback for more information.

The code below demonstrates an alternate way to initiate an instance of the COM server:

Dim HTM As Object
Set HTM = CreateObject("VerityHtmServ.Application")

where HTM is the COM Automation Server object.


_HP_HTML5_bannerTitle.htm