Our version of Amyuni Pdf Converter is 2.08, we are running under a server with windows 2000. We are trying to lock the amyuni printer, but the response that we get back from the lock is always 0. We can put in an invalid name and it still comes back 0. We have paused the amyuni printer and put that spooled name into the lock fuction, but have had no luck locking it. Is there any documentation explaining how to use the lock and unlock function. Here is the code that we are using, thanks for your help
Public Function GeneratePDFWithParmsAndImpersonate(strReportName As Variant, strFileName As Variant, arrReportParms() As Variant, vUserID As String, vPassWord As String) As Variant
On Error GoTo ErrorHandler
Dim CRRpt As CRAXDRT.Report
Dim PDFPrinter As CDIntf.CDIntf
Dim strResult As String
Dim i As Integer
Dim objLogon As Object
' Dim strReportIIS As String
Dim lngHostLevel As Long
Dim strAmyUniPrinter As String
Dim strProgressIndicator As String
Dim strResponseFromPrinter As Long
'lngHostLevel = GetHostLevelID 'Get Amyuni Printer name from Registry
strProgressIndicator = "Get Amyuni Printer name from Registry, "
strAmyUniPrinter = GetAmyuniPrinter
strProgressIndicator = strProgressIndicator & "Amyuniprinter name is - " & strAmyUniPrinter & " , "
'Create PDF Print object
strProgressIndicator = strProgressIndicator & "Create PDF Print object, "
Set PDFPrinter = CreateObject("CDIntf.CDIntf", strAmyUniPrinter)
'CreateObject for LoginAdmin Impersonate
strProgressIndicator = strProgressIndicator & "CreateObject for LoginAdmin Impersonate, "
Set objLogon = CreateObject("LoginAdmin.ImpersonateUser")
'Logon to M drive
strProgressIndicator = strProgressIndicator & "Logon to M drive, "
objLogon.Logon vUserID, vPassWord, "SD"
'Open report
strProgressIndicator = strProgressIndicator & "Open report, "
Set CRRpt = CRApp.OpenReport(strReportName)
'Set report parameters
strProgressIndicator = strProgressIndicator & "Set report parameters, "
For i = 0 To UBound(arrReportParms) - 1
CRRpt.ParameterFields.Item(i + 1).AddCurrentValue (arrReportParms(i))
Next
'Initialize print driver for use
strProgressIndicator = strProgressIndicator & "Initialize print driver for use, "
PDFPrinter.DriverInit "Amyuni PDF Converter"
'Set default file name
strProgressIndicator = strProgressIndicator & "Set default file name, "
PDFPrinter.DefaultFileName = strFileName
'*** very important to set as default printer
strProgressIndicator = strProgressIndicator & " very important to set as default printer, "
PDFPrinter.SetDefaultPrinter
'Set printer options
strProgressIndicator = strProgressIndicator & "Set printer options, "
PDFPrinter.FileNameOptions = NoPrompt + UseFileName
'Print Report
strProgressIndicator = strProgressIndicator & "Print Report, "
CRRpt.SelectPrinter "Amyuni PDF Converter 2.08", "Amyuni PDF Converter", "LPT1"
'lock amyuni printer
strProgressIndicator = strProgressIndicator & strProgressIndicator & "lock amyuni printer, "
strResponseFromPrinter = PDFPrinter.Lock("Crystal Reports ActiveX Designer - 212-Report_C.rpt")
'set rpt printout to false
strProgressIndicator = strProgressIndicator & "set rpt printout to false, "
CRRpt.PrintOut False
Set CRRpt = Nothing
'Reset all printer options before returning
strProgressIndicator = strProgressIndicator & "Reset all printer options before returning, "
PDFPrinter.FileNameOptions = 0
'unlock amyuni printer
strProgressIndicator = strProgressIndicator & "unlock amyuni printer, "
strResponseFromPrinter = PDFPrinter.Unlock("Crystal Reports ActiveX Designer - 212-Report_C.rpt", 30000)
Set PDFPrinter = Nothing
'perform Logoff of Impersonation
strProgressIndicator = strProgressIndicator & "perform Logoff of Impersonation "
objLogon.Logoff
Set objLogon = Nothing
'Return
GeneratePDFWithParmsAndImpersonate = ""
Exit Function
ErrorHandler:
strResponseFromPrinter = PDFPrinter.Unlock("Crystal Reports ActiveX Designer - 212-Report_C.rpt", 30000)
GeneratePDFWithParmsAndImpersonate = "V2 ERROR::Error in GeneratePDFWithParmsAndImpersonate Progress indicator: " & strProgressIndicator & " Err description " & Err.Description
End Function
Not able to lock amyuni printer
Hello,
Below is a snippet of Visual Basic code that illustrates how to implement the Locking Mechanism of the PDF Converter. The Lock function can be used in multi-threading situations to avoid conflicts between multiple applications or multiple threads requesting simultaneous access the Converter products. The CDIntf library uses the registry to interact with the printer drivers. When the Lock function is used, the output file name and options are set using the SetDocFileProps function and not from the SetDefaultFileName and SetFileNameOptions functions.
The Unlock function is used after printing has ended to make sure another printout can start. The call to Unlock is needed only in the case where an error occurs; the printer will otherwise call Unlock internally as soon as printing starts to allow another printout to occur in parallel. The Timeout value represents the Timeout in milliseconds after which the function returns.
Private Sub Command1_Click()
Dim DocTitleWord As String
DocTitleWord = "Microsoft Word - lock.doc"
pdf.DriverInit PrinterName
pdf.SetDefaultPrinter
pdf.Lock(DocTitleWord)
pdf.SetDocFileProps DocTitleWord, 3, _
"C:\temp", _
"C:\temp\lock.pdf"
printWord (strFile) 'this is a fucntion that prints a word doc
pdf.Unlock DocTitleWord, 1000
pdf.FileNameOptions = 0
pdf.RestoreDefaultPrinter
'pdf.FileNameOptions = 0
End Sub
Hope this helps?
Thanks
Below is a snippet of Visual Basic code that illustrates how to implement the Locking Mechanism of the PDF Converter. The Lock function can be used in multi-threading situations to avoid conflicts between multiple applications or multiple threads requesting simultaneous access the Converter products. The CDIntf library uses the registry to interact with the printer drivers. When the Lock function is used, the output file name and options are set using the SetDocFileProps function and not from the SetDefaultFileName and SetFileNameOptions functions.
The Unlock function is used after printing has ended to make sure another printout can start. The call to Unlock is needed only in the case where an error occurs; the printer will otherwise call Unlock internally as soon as printing starts to allow another printout to occur in parallel. The Timeout value represents the Timeout in milliseconds after which the function returns.
Private Sub Command1_Click()
Dim DocTitleWord As String
DocTitleWord = "Microsoft Word - lock.doc"
pdf.DriverInit PrinterName
pdf.SetDefaultPrinter
pdf.Lock(DocTitleWord)
pdf.SetDocFileProps DocTitleWord, 3, _
"C:\temp", _
"C:\temp\lock.pdf"
printWord (strFile) 'this is a fucntion that prints a word doc
pdf.Unlock DocTitleWord, 1000
pdf.FileNameOptions = 0
pdf.RestoreDefaultPrinter
'pdf.FileNameOptions = 0
End Sub
Hope this helps?
Thanks