Page 1 of 1

PDFSaver4.exe hangs

Posted: Wed Aug 17, 2011 9:44 am
by rainerraebiger
Hi all,

i have a problem with printing from an Access Application to PDF-XChange.

Within a VBA-Code a PDF-XChange Object is created, PDF-Options are done, set as default printer and then a report is opened to be printed.

I do not create and destroy the object for each print job, because i have to print thousands of documents at one time. Recreating the object cost to much time.

So after printing so documents the printing dialog in Access hangs (see Screenshot). When stopping the process PDFSaver4.exe Access goes on with printing.

System:
Windows XP SP3
PDF-Xchange 4.0.197.0
Access 2007 SP2

My Source:
Option Compare Database
Option Explicit

Public sError As String
Public PaperSize As AcPrintPaperSize
Public Orientation As AcPrintOrientation

Private Const olPrinterPDFXChange As String = "PDF-XChange 4.0"
Private moPDFPrinter As PXCComLib.CPXCPrinter
Private moPrinter As Access.Printer
Private iCounter As Integer
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)

Public Function bStore(sReport As String, sRecordSource As String, sFilter As String, sPath As String, sFilename As String) As Boolean

Dim bOpenReport As Boolean
Dim oReport As Report
Dim oStandardPrinter As Printer

' PDF-XChange initialize
Call msGetPDFPrinter(Me.msInitPDFPrinter)

' Save Standardprinter
Set oStandardPrinter = Application.Printer

' Set PDF-XChange as Standardprinter
Set Application.Printer = moPrinter

' Set PDF-XChange Options
Call Me.msSetPDFOptions(sPath & sFilename, sFilename)

bOpenReport = oReport Is Nothing

If bOpenReport Then
If Len(sRecordSource) > 0 And Len(sFilter) > 0 Then
DoCmd.OpenReport sReport, acPreview, sRecordSource, sFilter, acHidden
ElseIf Len(sRecordSource) > 0 Then
DoCmd.OpenReport sReport, acPreview, sRecordSource, , acHidden
ElseIf Len(sFilter) > 0 Then
DoCmd.OpenReport sReport, acPreview, , sFilter, acHidden
Else
--> here's the line to open and print
DoCmd.OpenReport sReport, acViewNormal, , , acWindowNormal
-->
End If
End If

' Restore Standardprinter
Set Application.Printer = oStandardPrinter

bStore = True

endd:

' Destroy Objects
Set oStandardPrinter = Nothing
Set oReport = Nothing

--> A Try to reset PDF-XChange each 100 documents DOES NOT HELP!
iCounter = iCounter + 1
If iCounter >= 1000 Then
Set moPDFPrinter = Nothing
DoEvents
DoCmd.Hourglass True
Sleep 75000 ' Wait to give pdfSaver4.exe time to exit
DoCmd.Hourglass False
iCounter = 0
End If

Exit Function

errh:
sError = Err.Description
Resume endd
End Function

Public Function msInitPDFPrinter() As String

If moPDFPrinter Is Nothing Then
Dim oPrinterTools As New OLSysPrint51.PrinterTools
Set moPDFPrinter = oPrinterTools.oGetPDFPrinter(goMandant.oLicense)
moPDFPrinter.SetAsDefaultPrinter
moPDFPrinter.RestoreDefaultPrinter
Set oPrinterTools = Nothing
End If
msInitPDFPrinter = moPDFPrinter.Name

End Function

Public Function msSetPDFOptions(sFilename As String, _
sTitle As String, _
Optional bRunApp As Boolean = False) As String

Dim sFile As String
Dim sPath As String

sPath = gsExtractPath(sFilename)
If sPath = "" Then
sPath = gsGetSpecialFolder
End If

sFile = gsFilenameRemoveChars(gsExtractFile(sFilename))
sFile = gsTrimExtension(sFile) & ".pdf"

If Not moPDFPrinter Is Nothing Then

moPDFPrinter.ResetDefaults
With moPDFPrinter
.Option("Save.SaveType") = "Save"
.Option("Save.ShowSaveDialog") = "No"
.Option("Save.WhenExists") = "Overwrite"
.Option("Save.RunApp") = bRunApp

.Option("Save.Path") = sPath
.Option("Save.File") = sFile

.Option("DocInfo.Enabled") = "Yes"
.Option("DocInfo.Title") = sTitle
.Option("DocInfo.Subject") = sTitle
.Option("DocInfo.Author") = gsCStr(goMandant.vntProperty(1))
.Option("DocInfo.Creator") = gsString(2) & _
" " & _
Left$(gsLibraryVersion, Len(gsLibraryVersion) - 1) & _
"." & _
Right$(gsLibraryVersion, 1)

.Option("Saver.ShowProgress") = "No"
.Option("Fonts.EmbedAll") = "Yes"
End With
msSetPDFOptions = sPath & sFile
End If

End Function

Private Sub msGetPDFPrinter(sPDFPrinter As String)

If moPrinter Is Nothing Then
Set moPrinter = Printers(sPDFPrinter)
End If

End Sub

Re: PDFSaver4.exe hangs

Posted: Thu Aug 18, 2011 11:50 am
by Tracker Supp-Stefan
Hello rainerraebiger,

I spoke with the guys from the dev team, and they told me that they will need some time to investigate this case. So they are requesting for your patience while they manage to get to the problem. We hope to be able to answer you around the middle of next week.

Best,
Stefan

Re: PDFSaver4.exe hangs

Posted: Mon Aug 22, 2011 10:59 pm
by rainerraebiger
Hi Stefan,

this is ok. I would wait even two weeks to get a solution.

Regards
Rainer

Re: PDFSaver4.exe hangs

Posted: Tue Aug 23, 2011 1:22 pm
by Tracker Supp-Stefan
Thanks for the understanding Rainer,

And we will try to find a solution for you as fast as possible, and will post here in the forums as soon as we have any news.

Best,
Stefan

Re: PDFSaver4.exe hangs

Posted: Fri Aug 26, 2011 9:24 am
by Ivan - Tracker Software
Could you please send me (attach to the forum topic or send to my email: Ivan@tracker-software.com) the Access file you are using with which I could try to reproduce the problem?

Re: PDFSaver4.exe hangs

Posted: Tue Sep 06, 2011 11:00 am
by rainerraebiger
Ivan - Tracker Software wrote:Could you please send me (attach to the forum topic or send to my email: Ivan@tracker-software.com) the Access file you are using with which I could try to reproduce the problem?
Hi Ivan,

sorry for this late reply. This Access Addin is part of a large ERP-Systems based on Access. I'm not sure if having only this Addin will really help you.

Are there other ways i can support you?

Regards
Rainer Raebiger

Re: PDFSaver4.exe hangs

Posted: Mon Sep 12, 2011 4:50 pm
by Ivan - Tracker Software
Please try to kill pdfSaver4.exe process before printing, run it manually (by default pdfSaver4.exe is located into PDF-XChange installation folder), and check if the problem still exists.