'Convert PDF to Image' COM/ActiveX Interface

Using 'Convert PDF to Image' as an ActiveX Component

Overview

For COM+ (i.e. with IIS) users click here.

 

One very important note is that the file, ConvertPDFtoImage.EXE, is both an executable application AND an ActiveX component.  Again, the file ConvertPDFtoImage.EXE, can be run as a stand-alone executable as well as be referenced as a component within your development environment. There is only one installation for 'Convert PDF to Image'. ConvertPDFtoImage.exe is installed in the Program Files folder of your operating system.


For Visual Basic users, simply make a reference to the ConvertPDFtoImage.EXE application in the Tools\References menu item.  Once done you now have access to the component. In other development environments such as VBA you may use something similar to the lines of code below to create an instance of the application object:

    Dim oConvertAppObject as Object

    Set oConvertAppObject = CreateObject("ConvertPDFtoImage.clsConvertPDFToImage")

    Call oConvertAppObject.DoCommandLine("/JE:\Jobs\Test.SII")


Directly below is some VBS (Visual Basic Script). You could put the following 3 lines in a text file, call it Test.VBS and give it a go:

   set converter = WScript.CreateObject("ConvertPDFtoImage.clsConvertPDFToImage")
   result = converter.DoCommandLine("/JE:\Jobs\Test.SII")
   MsgBox(result)
 

To download demonstration source code (VB6 and VB.NET) click the following links:

Here is some sample VB code illustrating its usage:

Private Sub Command1_Click()

  Dim lRetVal As Long

  Dim cpti As ConvertPDFtoImage.clsConvertPDFToImage

 

  Set cpti = New ConvertPDFtoImage.clsConvertPDFToImage

' Assign Key To the 'Final Key', given upon purchase/registration.

   cpti.Key = ""

  ' Run by the command line.  See documentation for a full listing of

  ' switches and options. Switches are CASES SENSITIVE

 

  ' Convert Test.PDF to Output.JPG.

  '   Verbose output with /V. Remove /V to make it completely silent.

  '   Specify the source (/S) and target files (/T),

  '   the JPG format (/C1) of the target image file,

  '   also specify which page(s) to do with /1 * (in this case all),

  '   and the resolution with /5 (in this case 200 DPI),

  '   JPEG Quality 90% with /4:

 

  lRetVal = cpti.DoCommandLine("/S C:\Input\Coffee.PDF /T C:\Output\Coffee.JPG /C1  /1 * /4 90 /5 200 /V")

 

'  Example of specifying a 'Conversion Job File'

  lRetVal = cpti.DoCommandLine("/j""C:\Test\cj.sii""")

 

' DoCommandLine() Return Values

'  0 = Success

' -1 = Shareware expired

' -2 = Command line String Empty or invalid

' -3 = Missing required or invalid command line argument(s)

  If (lRetVal = 0) Then

    MsgBox ("Success!")

  Else

    MsgBox ("Failure.")

  End If

  Set cpti = Nothing

End Sub

 

As you can see from the code above, the ActiveX simply wraps the command line feature. So, to learn what you can do with the ActiveX, please refer to the 'Using the Command Line' section of the 'Convert PDF to Image' user's manual

METHODS

     DoCommandLine()
     DESCRIPTION:

      This function emulates doing the command line, but through the COM interface.

      RETURN VALUES:
         0 = Success
        -1 = Shareware expired
        -2 = Command line String empty or invalid
        -3 = Missing required command line argument(s)
        -X = Some error occurred during the processing, create a log or use verbose switch for details

 

PROPERITES

None

EVENTS

     OnError(lErrorNumber As Long, sErrorString As String)
     DESCRIPTION:

      When an error occurs this event is triggered supplying both the error code and description.  This can be very helpful while troubleshooting and developing.