Modify to capture PDF Converter Events

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
Dana Perkins
Posts: 5
Joined: Tue Oct 09 2007
Location: Portland, Maine
Contact:

Modify to capture PDF Converter Events

Post by Dana Perkins » Wed Dec 12 2007

In vb6 I have been able to successfully capture events when placing the PDF Converter as a control on the form, but have not been able to do so with the following code. This code does PDF ok, I just don't know how to capture events.

Code: Select all


   Const strActivationCode = "xxx"
    Const strLicensedTo = "AMS Services Inc."
    Const strPDFPrinterName = "Test PDF Converter"

' ******************** other Declarations *******************
Private Declare Function ShellExecute _
    Lib "shell32.dll" _
    Alias "ShellExecuteA" _
    (ByVal hWnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) As Long

Private Declare Function GetDesktopWindow _
    Lib "user32" () As Long

Public Function CreatePDFPrinter() As Long

    Dim X As Printer

    ' create pdf converter if it doesn't exist - if it does, attach to it
    hPDF1 = PDFDriverInit("ABK PDF Converter")
    ' following call leaves pdf converter on system even if 'DriverEnd' called
    hPDF1 = DriverInit("ABK PDF Converter")
    
    If hPDF1 = 0 Then
        MsgBox "Cannot initialize PDF Converter"
        End
    End If
    
    ' set file name options
    For Each X In Printers
        Select Case X.DeviceName
            Case "ABK PDF Converter"
                Set Printer = X
                If GetDocPrintPDFPageCompression = 0 Then
                    SetFileNameOptions hPDF1, NoPrompt + UseFileName + Concatenate + DisableCompression
                Else
                    SetFileNameOptions hPDF1, NoPrompt + UseFileName + Concatenate
                End If
                'If bCreatePDF = True Then
                    SetVerticalMargin hPDF1, GetDocPrintPDFVerticalMargin
                    SetHorizontalMargin hPDF1, GetDocPrintPDFHorizontalMargin
                    SetResolution hPDF1, 600
                    SetDefaultConfig hPDF1
                    SetDefaultFileName hPDF1, "c:\temp\text1.pdf"
                'End If
                'Need to Enable Printer before every print job
                EnablePrinter hPDF1, strLicensedTo, strActivationCode"
       End Select
    Next X
    
    CreatePDFPrinter = hPDF1
End Function

Private Sub Command1_Click()
    CommonDialog1.ShowOpen
    Text1.Text = CommonDialog1.Filename
    
End Sub

Private Sub Command2_Click()
    
    MousePointer = vbHourglass
    hPDF1 = CreatePDFPrinter
    SetDefaultPrinter (hPDF1)
    ShellExecute GetDesktopWindow, "Print", Me.Text1.Text, "", "C:\temp", 0
    RestoreDefaultPrinter (hPDF1)
    MousePointer = vbDefault
    
End Sub
How do I code this to capture events?
-- Dana[/code]

Post Reply