Queue.MergeAllJobs() leaves a job orphaned


#1

I’m supporting a client using PDF Creator. The app is using the COM interface/libraries.

Environment:
Their current version of PDF Architect Creator is 3.0.2, on Windows Server 2008 R2 Datacenter. Users connect to a desktop session on this server via Remote Desktop. The application using PDF Creator is Microsoft Access 2010 (VBA).

Issue:
An issue that I am trying to resolve is with the Queue. Specifically, the MergeAllJobs() method.

The problem is that sometimes all the jobs in the queue are successfully merged, but sometimes the final job is left orphaned in the queue. When I check the Queue.Count value, it is 0 even though that orphaned job is still there.

Please help. The solution I am supporting and maintaining depends on this feature functioning correctly.


Any idea if the VBA bug "works every second time" will be adressed?
Any idea if the VBA bug "works every second time" will be adressed?
#2

Hi,

we will need to look into this, have you checked if it might be a timing issue (e.g. the last job sometimes finishes spooling after the MergeAllJobs is called?) ?

Best regards,

Robin


#3

As far as I am able to tell, it is not a timing issue. After the call to the [AddFileToQueue] method, I’m using this statement in my code:

If Not pdfQueue.WaitForJobs(1, 7) Then


#4

Perhaps this is the same/similar issue that I am encountering…


#5

I realized that I was trying to use an unsupported method - I was trying to enque non postscript files, pushing them directly to the PDFCreator queue. Instead, I have a working solution by using Acrobat Reader to "print" to the PDFCreator printer; this provides the postscript file that PDFCreator expects and it queues the job. Here's some code snippets that work for my implementation:

Public Sub PDFCreatorPrint(vFromPaths As Variant, fullPath As String, Optional vAddBlankPage As Boolean, Optional vPageCount As Long)
Dim PDFCreatorQueue As Variant
Dim printJob As Variant

Set PDFCreatorQueue = CreateObject("PDFCreator.JobQueue")

On Error GoTo Err_exit

Set printJob = CreateObject("PDFCreator.PdfCreatorObj")

On Error GoTo Err_exit

If Not isPDFCreatorRunning Then
    PDFCreatorQueue.Initialize
Else
    Set PDFCreatorQueue = Nothing
    Set printJob = Nothing
    Exit Sub
End If

...

SetApplicationPrinter "PDFCreator" 'custom procedure to set Application.Printer

...

'timing parameters
Dim dTime As Date, T As Integer, beg As Integer, n As Date, pdfOutput
n = Now
T = 30
beg = 0

'Queue the documents contained in vPath
Dim jobCount As Integer, vPath, strExecutable As String
jobCount = 0
For Each vPath In Split(CStr(vFromPaths), ",")
    If Dir(CStr(vPath)) <> "" Then 'file exists
        If getAdobeReaderPath And gAcroRd32 <> "" Then 'Acrobat Reader is installed and recognized
            strExecutable = Chr$(34) & gAcroRd32 & Chr$(34) & " /N /H /T "
            strExecutable = strExecutable & Chr$(34) & vPath & Chr$(34)
            strExecutable = strExecutable & " " & Chr$(34) & Application.Printer.DeviceName & Chr$(34)
            
            Shell strExecutable, vbHide 'use Acrobat Reader to "print" to the PDFCreator printer, i.e., queue each document
        
            DoCmd.Hourglass True
            
            dTime = DateAdd("s", T, Now)
            jobCount = jobCount + 1
            
            Do Until PDFCreatorQueue.Count = jobCount Or Now > dTime 'wait
                'iterate
                beg = beg * 0
            Loop
            
            DoCmd.Hourglass False
            
            'check if file made it into the queue
            If PDFCreatorQueue.Count < jobCount Then
                MsgBox "PDFCreator - unable to add the file [" & vPath & "] to the queue.", vbOKOnly, "PDFCreator"
            End If
        End If
    Else
        MsgBoxCall "Unable to locate " & vPath & " - file does not exist.", vbOKOnly, "PDFCreator"
    End If
Next vPath

dTime = DateAdd("s", 60, Now)
T = 7
beg = 0
Do Until PDFCreatorQueue.Count = jobCount Or Now > dTime 'wait
    If Not PDFCreatorQueue.WaitForJobs(jobCount, T) Then
        'iterate
        beg = beg + T
    End If
Loop
If PDFCreatorQueue.Count > 0 Then
    
    PDFCreatorQueue.MergeAllJobs
    
    Set printJob = PDFCreatorQueue.NextJob
    
    printJob.SetProfileSetting "OpenViewer", "False"
    
    printJob.ConvertTo (fullPath) 'produce the final merged PDF doc
    
    If (Not printJob.IsFinished Or Not printJob.IsSuccessful) Then
        MsgBox "PDFCreator - Could not convert the file: " & fullPath, vbOKOnly, "PDFCreator"
    End If
End If

On Error GoTo 0

Err_exit:
If Err.Number &lt;&gt; 0 Then
MsgBox "Could not create the file at " &amp; fullPath &amp; ". An error occurred while printing to the PDFCreator printer " &amp; Application.Printer.DeviceName &amp; ". Error " &amp; Err.Number &amp; " - " &amp; Err.Description, vbOKOnly, "PDFCreator Error"
End If

PDFCreatorQueue.ReleaseCom

Set PDFCreatorQueue = Nothing
Set printJob = Nothing

...

Blockquote