Printer Handle returned by PDFDriverInit

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:

Printer Handle returned by PDFDriverInit

Post by Dana Perkins »

I am using the PDF Converter from VB6 code. I have declared all the needed functions in a module and when I Initialize the driver with PDFDriverInit or DriverInit, I do get a handle (as long) returned from the function.

Code: Select all

Public Function CreatePDFPrinter() As Long

    Dim X As Printer
    Dim pPhnxPrinter As CPhnxPrinter 'this may no longer be needed
    Dim m_strDeviceName As String
    
    ' 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"
        Call EndProgram
    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
                'End If
                'Need to Enable Printer before every print job
                EnablePrinter hPDF1, "strLicensedTo", strLicenseCode
       End Select
    Next X
    
    CreatePDFPrinter = hPDF1

End Function
-------------------
However, if I create a reference to the dll (Project/References/browse) and then have code as follows, a zero rather than a handle is returned. The program does PDF as desired, but I expected to get back a non-zero number. The documentation says to expect a null if unsuccessful and a handle if successful. Why aren't I getting back a handle? I would not expect the handle to always be zero - which is what I get back.

Code: Select all

Option Explicit
Public WithEvents pdfEvent As CDIntfEx.CDIntfEx

Public Function CreatePDFPrinter() As Long
    Set pdfEvent = New CDIntfEx.CDIntfEx
    hPDF1 = pdfEvent.PDFDriverInit(PDFPrinter)
    hPDF1 = pdfEvent.DriverInit(PDFPrinter)
    pdfEvent.CaptureEvents (1)

    If GetDocPrintPDFPageCompression = 0 Then
        pdfEvent.FileNameOptions = NoPrompt + UseFileName + Concatenate + DisableCompression
    Else
        pdfEvent.FileNameOptions = NoPrompt + UseFileName + Concatenate
    End If
    pdfEvent.VerticalMargin = GetDocPrintPDFVerticalMargin
    pdfEvent.HorizontalMargin = GetDocPrintPDFHorizontalMargin
    pdfEvent.Resolution = 600
    pdfEvent.SetDefaultConfig
    pdfEvent.EnablePrinter strLicenseTo, strActivationCode
    pdfEvent.SetDefaultPrinter    
    CreatePDFPrinter = hPDF1  

End Function

-- Dana
David
Amyuni Team
Posts: 89
Joined: Mon Dec 18 2006

Post by David »

Hello

Using the Amyuni DLL interface:
If the DriverInit function succeeds, the return value is an internal handle to the printer. If the function fails, the return value is NULL.

In the Amyuni ActiveX interface:
If the DriverInit function succeeds, the return value is 0. If the function fails, it launches an exception and there is no return value in this case.

Hope that helps
David
Dana Perkins
Posts: 5
Joined: Tue Oct 09 2007
Location: Portland, Maine
Contact:

Post by Dana Perkins »

Thanks! The documentation should be updated to reflect this.
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello Dana,

The latest version of the documentation is updated to reflect this.

Please check "Common Driver Interface 300.pdf" pages 13 and 100.

Merry Christmas :-)
Custom Brand the Amyuni PDF Printer Driver http://www.amyuni.com/en/developer/branding/index.html

Amyuni PDF Converter tested for true PDF performance. View results - http://www.amyuni.com/benchmark
Dana Perkins
Posts: 5
Joined: Tue Oct 09 2007
Location: Portland, Maine
Contact:

Thanks!

Post by Dana Perkins »

Thanks!
Post Reply