Am trying to print a document on a shared printer; i need to get print queue details.The following code always gets queue from 'Microsoft XPS Document' as Number of jobs=0.But my default printer is configured as 'HP LaserJet P1505n'
LocalPrintServer server = new LocalPrintServer()
PrintQueueCollection queueCollection = server.GetPrintQueues();
PrintQueue printQueue = null;
foreach (PrintQueue pq in queueCollection)
{
Logger.LogInfo("PrintQueue1", "Printer1 Queue Name " + pq.FullName);
printQueue = pq;
numberOfJobs = printQueue.NumberOfJobs;
Logger.LogInfo("numberOfJobs1"+ numberOfJobs);
}
How to get print queue details from that specific shared printer? i tried following also
PrintServer server = new PrintServer(@"\\192.168.100.168\HP LaserJet P1505n");
but got error as:
Win32 error: The filename, directory name, or volume label syntax is incorrect
What am i missing here?
How to get print queue details from that specific shared printer?
Try something like this:
// string.Empty or null for local printers
string printServerName = @"\\server";
string printQueueName= "printer";
PrintServer ps = string.IsNullOrEmpty(printServerName)
// for local printers
? new PrintServer()
// for shared printers
: new PrintServer(printServerName);
PrintQueue pq = ps.GetPrintQueue(printQueueName);
Console.WriteLine(pq.FullName);
Console.WriteLine(pq.NumberOfJobs);
// output is printer uri (\\server\printer) and 0.
Is also possible use server ip address (like string) instead server name.
string printServerName = @"\\192.168.1.111"; // for example
i.e
for local printer PDFCreator set
string printServerName = null;
string printerName = "PDFCreator";
and for shared printer P on server S set
string printServerName = @"\\S";
string printerName = "P";