[SOLVED] pdfcreator migrating com interface to version 2

Author: mps59@orange.fr (mpservices)

Hi I have to move pdfcreator from version 1.7 to 2.x , using the com interface, I took over  the 1.7 version uniface form  : using the signature  "CLSPDFCREATOR start, set_coption,get_ccountofprintjobs..., the form was working well so until now no problem I've imported the signatures for version 2.x,but Im' stucked from the beginning, I'm not familiar at all with the com interface  Has anyone a little example how to use  it : creating Queue,initialise.... (using uniface 9.6) Thanks in advance Dominique

1 Comment

  1. Hi Dominique, When you check the samples provided with PDFCreator 2.x (see sub-directory \COM Scripts\ in the installation directory) then you should find plenty information about how to use the different methods/properties of the PDF Creator COM interface. Here's (e.g.) some VB.net code (from \COM Scripts\VB.Net\COM_TestForm\COM_TestForm\Form1.vb) to print a test page:

    Private Sub testPage_btn_Click(sender As Object, e As EventArgs) Handles testPage_btn.Click Dim PDFCreatorQueue As pdfforge.PDFCreator.COM.Queue Dim PrintJob As pdfforge.PDFCreator.COM.PrintJob Dim assemblyDir, fullPath As String PDFCreatorQueue = New pdfforge.PDFCreator.COM.Queue() Try assemblyDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) assemblyDir = assemblyDir.Replace("\bin\Debug", "\Results") fullPath = Path.Combine(assemblyDir, "TestPage_2Pdf.pdf") MsgBox("Initializing PDFCreator queue...") PDFCreatorQueue.Initialize() MsgBox("Printing windows test page...") printFile() If Not PDFCreatorQueue.WaitForJob(10) Then MsgBox("The print job did not reach the queue within " & " 10 seconds") Else MsgBox("Currently there are " & PDFCreatorQueue.Count & " job(s) in the queue") MsgBox("Getting job instance") PrintJob = PDFCreatorQueue.NextJob PrintJob.SetProfileByGuid("DefaultGuid") MsgBox("Converting under ""DefaultGuid"" conversion profile") PrintJob.ConvertTo(fullPath) If (Not PrintJob.IsFinished Or Not PrintJob.IsSuccessful) Then MsgBox("Could not convert the file: " & fullPath) Else MsgBox("Job finished successfully") End If End If Catch Ex As Exception MessageBox.Show("Original error: " & Ex.Message) Finally MsgBox("Releasing the queue object") PDFCreatorQueue.ReleaseCom() End Try ' End If End Sub

    The above sample would look in Uniface like this (without error checking):

    ; Sample code is based on the imported COM signatures that are created by: ; /sti /mwr=com /pid PDFCreator.JobQueue variables boolean bResult, bJobIsFinished, bJobIsSuccessful handle hPDFCreatorQueue, hPrintJob numeric nJobCount string fullPath endvariables newinstance "Queue", hPDFCreatorQueue fullPath = $concat($ldir(), "TestPage_2Pdf.pdf") message/info "Initializing PDFCreator queue..." hPDFCreatorQueue->Initialize() message/info "Printing test page..." print "PRINTER" hPDFCreatorQueue->WaitForJob(bResult, 10) If (!bResult) message/error "The print job did not reach the queue within 10 seconds" Else hPDFCreatorQueue->Get_Count(nJobCount) message/info $concat("Currently there are ", nJobCount, " job(s) in the queue") message/info "Getting job instance" hPDFCreatorQueue->Get_NextJob(hPrintJob) hPrintJob->SetProfileByGuid("DefaultGuid") message/info "Converting under %%"DefaultGuid%%" conversion profile" hPrintJob->ConvertTo(fullPath) hPrintJob->Get_IsFinished(bJobIsFinished) hPrintJob->Get_IsSuccessful(bJobIsSuccessful) If (!bJobIsFinished | !bJobIsSuccessful) message/error $concat("Could not convert the file: ", fullPath) Else message/info "Job finished successfully" EndIf EndIf message/info "Releasing the queue object" hPDFCreatorQueue->ReleaseCom()

    Hope this helps. Kind regards, Daniel Iseli Uniface Technical Support

    Author: diseli (daniel.iseli@uniface.com)