Help Contents

Using Print2HTML5 OLE Automation API

To make use of Print2HTML5 OLE Automation API you need to consult your programming language or tool documentation to learn how to create and access OLE Automation objects from it. After you learn how to create OLE Automation objects in your language or tool, you can start using Print2HTML5 OLE Automation API. Basically this involves importing of Print2HTML5 OLE Automation API type library (TLB) file (p2hserver.tlb) or Interface Definition Language (IDL) file (p2hserver.idl). These files are located in Print2HTML5 SDK directory.

One of the problems using Print2HTML5 OLE Automation API from web page server scripts may be the fact that such scripts usually run under very restricted user account which may prevent the printing applications from proper working and sending document output to Print2HTML5 printer. In such a case it may be necessary to make Print2HTML5 server work under another user or administrator account with proper rights. This may be achieved with Setting up Automation Object User Account.

Below is the instruction on how to use Print2HTML5 Automation API from VBScript but this discussion and involved API usage technique pertains to other languages as well. The Print2HTML5 Automation API Reference contains comprehensive documentation for all languages and API usage samples for VBScript.

Using Print2HTML5 Automation API from VBScript

Using Print2HTML5 Automation API from VBScript is, perhaps, the easiest and fastest way to start using this API as it does not involve using type libraries. VBScript can be used in Windows Script Host environment to run script directly from Windows Shell, from web pages or from ASP scripts. Below we'll consider creating scripts for Windows Script Host as the simplest way to explore Print2HTML5 Automation API.

First, you need to create a Print2HTML5 Server object in this way:

set P2H=CreateObject("Print2HTML5.Server")
Then you may convert a single document to HTML5 using a simple call such as this:
P2H.ConvertFile "C:\Docs\MyDoc.txt"
To test this functionality, create a file named testp2hapi.vbs, put those two lines there (changing the path to the document to a real document path), save the file and launch it by double clicking it in Windows Explorer. The script should convert the specified file and save resulting HTML5 document to the same folder where the original file resides under the name of the original document but with .xml extension appended to it. For example, for the document name above, you'll get the file named C:\Docs\MyDoc.txt.xml (as well as the related resource folder C:\Docs\MyDoc.txt_files) as output.

Similarly, you may write additional code using Print2HTML5 Automation API Reference documentation and samples from there and test it by saving the code as .vbs files and launching the script.