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
-
Register the COM server by using one of the following methods:
-
Confirm the following entry is in the Windows registry:
\\HKEY_CLASS_ROOT\VerityHtmServ.Application
-
Create an instance of the COM object. See the
comsamp
sample for an example. -
Specify the source file by using the
pszInputFile
property. -
Specify the location of the HTML Export libraries by using the
pszKeyViewDir
property. -
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
-
Select References... from the Project menu.
-
Search available references for "HTML Export COM Server Library," and select it.
-
If the HTML Export COM Server Library is unavailable, follow the registering instructions in Use the COM Implementation of the API.
Sample Code
-
Declare the variable
MyRef
as an instance ofhtmserv
(the HTML Export COM server):Dim WithEvents MyRef As htmserv
-
Specify the source file by setting the input file property
pszInputFile
:Private Sub Convert_Click() MyRef.pszInputFile = File1.Path & "\" & File1.FileName
-
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
-
Call the
ConvertFileToFile
method:Convert: nRet = MyRef.ConvertFileToFile("c:\temp\temp.htm") WebBrowser1.Navigate ("c:\temp\temp.htm") Exit Sub
-
The
comsamp
sample program specifies the default directory for source files as theC:\Program Files\Autonomy\KeyviewExportSDK\testdocs
directory, and the directory in which binaries are stored as theC:\Program Files\Autonomy\KeyviewExportSDK\>OS\bin
directory, whereOS
is the name of the operating system. To change these directories to match your installation, set thePath
property to the location of thetestdocs
directory, and set thepszKeyViewDir
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
-
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
See Continue for more information.
-
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.