How to know if my document was successful printed using visual basic 2008

Posted by Krishnasamy2008 under ASP.NET on 1/28/2011 | Points: 10 | Views : 9707 | Status : [Member] | Replies : 1
Hi Friends,
I did a little aplication in VB2008, this aplication save several data about contacts, accounts, etc., and using this data you can generate a lot of documents with crystal reports, and send them to print using the network printers or locally.

My client need an upgrade of this program, he needs that any document send it to print has a consecutive number (to keep a record) and save this number in a database, but this number will be added only when the print operation was successful.

Do you know how can I catch with visual basic 2008 the event that happend when the document was printed??????

Thanks and Regards,
Krishna.K




Responses

Posted by: Karthikanbarasan on: 1/28/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi Krishna,

Check this code... here in the printer props u have the status... u can use the status to check if the job is completed or not

static void PrintProps(ManagementObject o, string prop)     

{
try
{
Console.WriteLine(prop + "|" + o[prop]);
}
catch (Exception e)
{
Console.Write(e.ToString());
}
}

static void Main(string[] args)
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Printer");
foreach (ManagementObject printer in searcher.Get())
{
string printerName = printer["Name"].ToString().ToLower();
Console.WriteLine("Printer :" + printerName);
PrintProps(printer, "Caption");
PrintProps(printer, "ExtendedPrinterStatus");
PrintProps(printer, "Availability");
PrintProps(printer, "Default");
PrintProps(printer, "DetectedErrorState");
PrintProps(printer, "ExtendedDetectedErrorState");
PrintProps(printer, "ExtendedPrinterStatus");
PrintProps(printer, "LastErrorCode");
PrintProps(printer, "PrinterState");
PrintProps(printer, "PrinterStatus");
PrintProps(printer, "Status");
PrintProps(printer, "WorkOffline");
PrintProps(printer, "Local");
}
}


Thanks
Karthik
www.f5Debug.net

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response