2

C# not getting any status of printer. I am printing and want to know status of printer whether "PRINTER IS PRINTING" or "PRINTER OUT OF PAPER".

Here is my code :-

            string filePath = "C:\\Users\\fouzan\\Desktop\\abc.txt";
            PrintDocument pd = new PrintDocument();
            Process p = new Process();
            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.CreateNoWindow = true;
            startInfo.WindowStyle = ProcessWindowStyle.Hidden;
            startInfo.UseShellExecute = true;
            startInfo.FileName = filePath;
            startInfo.Verb = "print";
            startInfo.Arguments = @"/p /h \" + filePath + "\"\"" +     pd.PrinterSettings.PrinterName + "\"";

            p.StartInfo = startInfo;
            MessageBox.Show(p.StartInfo.ToString());
            p.Start();
            MessageBox.Show(p.Start().ToString());


            LocalPrintServer server = new LocalPrintServer();
            PrintQueue printQueue = server.GetPrintQueue("Samsung ML-2160 Series");

            //this outputs "NONE":-
            MessageBox.Show(printQueue.QueueStatus.ToString());

I am getting "NONE" output how can I know if printer is printing or its "out of paper".

I have selected default printer "Samsung ML-2160 Series" from printer properties.

Lennart
  • 9,657
  • 16
  • 68
  • 84
  • 1
    If you set a breakpoint at `MessageBox.Show(printQueue.QueueStatus.ToString());`, are any of the properties set on `printQueue`? – Poosh Aug 18 '17 at 15:24
  • Looks like a duplicate of https://stackoverflow.com/questions/16370237/printqueuestatus-returns-none-printer-is-already-turned-off , which unfortunately does not have an answer. – sgmoore Aug 18 '17 at 15:38

0 Answers0