VB6 sample code for PDFC 2.1

Due to an update an old VB6 code (written in 2007) no longer worked. After a lot of time wasted searching in the net, I rewrote the code to create a PDF from any file.

Enjoy this code and share it :slight_smile:

-------------------------------------------------

A) add in references 'PDF Creator - Your opensource …'


Sub PDFCreator_CreatePDF(srcFORM As Form, srcFILE As String, dstFILE As String)

    Dim myPDF As New PdfCreatorObj
    Dim pdfQUEUE As New Queue
    Dim myJOB As PrintJob

    If myPDF.IsInstanceRunning Then
        MsgBox “PDF-Creator is already in use.” & vbNewLine & _
               “Wait for session end”, _
               vbInformation, _
               “WARNING”
        Exit Sub
    End If

    srcFORM.MousePointer = vbHourglass

    pdfQUEUE.Initialize

    Call myPDF.PrintFile(srcFILE)

    Do Until pdfQUEUE.Count > 0
        DoEvents
    Loop

    Set myJOB = pdfQUEUE.NextJob
    Call myJOB.SetProfileSetting(“OpenViewer”, “false”)
    Call myJOB.ConvertTo(dstFILE)

    Do Until myJOB.IsFinished
        DoEvents
    Loop

    Call pdfQUEUE.ReleaseCom

    Set myJOB = Nothing
    Set pdfQUEUE = Nothing
    Set myPDF = Nothing

    srcFORM.MousePointer = vbNormal

End Sub

-------------------------------------------------

Private Sub Command2_Click()

    ’ sample of use

    PDFCreator_CreatePDF Me, _
                         App.Path & “\test.doc”, _
                         App.Path & "\test.pdf"
End Sub

-------------------------------------------------


GbC