Question How to know print given to network printer is success or fail

Grasys

New member
Joined
Nov 6, 2009
Messages
4
Programming Experience
1-3
Hello All,

How to know print given to network printer is success or fail.
I have used PD.Print() to print check receipt. I want to know whether print is success or fail..if it fails i need to update database with success or fail.

Thanks,
Gra
 
Thanks John,
But if printer is out of paper..Win32_PrintJob returning unknown value. It is not working.
Please help me

Thanks,
Grasys
 
But if printer is out of paper..Win32_PrintJob returning unknown value. It is not working.
What do you mean "Win32_PrintJob returning unknown value" ? What is not working ?
 
John,

I have removed papers from printer and tryed to print. When i check "StatusMask" property it is returning "0". For "0" there is no meaning. I hope i have explined clearly.
If not please reply.

John, Searcher object taking more time to get PrintJobs. Is ther any .net framework way to get job's from specified printer.

Thanks,
Grasys
 
John,

I am printing content on check (before printing check number is inserted in DB). If print fails at any reason, i need to update check number with default number "000000".

Can you please tell me how can i achive this.

Regards,
Grasys
 
I have removed papers from printer and tryed to print. When i check "StatusMask" property it is returning "0". For "0" there is no meaning.
One of my tests show that if Status is "UNKNOWN" then StatusMask is 0, this may be because the mask is not initialized and the default Uint32 value 0 is returned. I can only guess this means job has not started yet, I tested with a paused non-paper printer. I will check later with a paper printer. It may be appropriate in such cases to investigate the status of the printer itself.
Searcher object taking more time to get PrintJobs. Is ther any .net framework way to get job's from specified printer.
No, there is WMI and the underlying Win32 functions, that can also be used directly but usually adds a lot of difficult code. "Searcher object", I prefer to generate VB proxy classes to use with WMI, way more convenient to handle. Post 5 in the linked thread show how you can do this. Here is my test code:
VB.NET:
Dim jobs As Win32.PrintJob.PrintJobCollection = Win32.PrintJob.GetInstances("Document=""doc42""")
If jobs.Count > 0 Then
    Dim job As Win32.PrintJob = CType(jobs(0), Win32.PrintJob)            
    Dim status As String = job.Status
    Dim mask As Win32.PrintJob.StatusMaskValues = job.StatusMask
    If status.ToLower = "unknown" Then
        Dim printer As Win32.Printer = CType(Win32.Printer.GetInstances("Name=""The printer name""")(0), Win32.Printer)
        Dim state As Win32.Printer.ExtendedPrinterStatusValues = printer.ExtendedPrinterStatus
        Stop
    End If
    Stop
End If
Stop
If you're uncertain about what properties to use or what values the different objects has at any time just query the class for all properties with WMI Code Creator and look at the values, refer to the documentation for what the various numeric values mean.
I am printing content on check (before printing check number is inserted in DB). If print fails at any reason, i need to update check number with default number "000000".
If you're asking how to interact with database then that is a different topic you should ask in a new thread in appropriate forum, for example Data Access forum or one of the forums in Database sections.
 
Back
Top