I wrote a program to print a pdf to a network print server, which works fine.
If I disconnect my network cable and print I get an error, event though I am trapping for the error.
The exception is:-
cete.DynamicPDF.Printing.PrintFailedException:Printjob could not be created in the spooler ...'
Here is the function:
Function PrintAJob(ByVal Filename As String) As Boolean
Dim MyPrintJob As PrintJob = New PrintJob(Printer.Default, Filename)
ErrorString = ""
AddHandler MyPrintJob.Failed, AddressOf Printer_PrintJobFailed
AddHandler MyPrintJob.Succeeded, AddressOf Printer_PrintJobSucceeded
AddHandler MyPrintJob.Updated, AddressOf Printer_PrintJobUpdated
Try
MyPrintJob.Print()
Catch pfe As ceTe.DynamicPDF.Printing.PrintFailedException
MessageBox.Show("Print Failed Exception: " + pfe.ToString)
Clipboard.SetText(pfe.ToString)
Catch pe As ceTe.DynamicPDF.Printing.PrintingException
MessageBox.Show("Printing Exception: " + pe.ToString)
Clipboard.SetText(pe.ToString)
End Try
Return (ErrorString = "")
End Function
Surely the try catch should trap it, I am coding in VS2008 Express.
thanks
Steve
Printing with no Network cable crashes
Re: Printing with no Network cable crashes
Support · Feb 23, 2010Hello Steve,
Actually, the Print method (of the PrintJob) is sending the actual print job to the spooler asynchronously. This means that the MyPrintJob.Print line of code is not going to throw any exception. So in your code above, nothing is ever going to be trapped.
You are correctly adding the handler (with "AddHandler MyPrintJob.Failed, AddressOf Printer_PrintJobFailed") but it is just that no events are being thrown during the MyPrintJob.Print.
Let us know if you have any more questions.
Thanks,
ceTe Software Support Team