1

Does PrintQueue or PrintTicket has any property or method to determine the selected printer is a virtual printer? For example, the process should restrict M/S Xps Document Writer, Fax, Send To OneNote, PDF Printer etc. Only actual printers should be filtered out from LocalPrintServer and provide a list dynamically.

    using (var _LocalPrintServer = new LocalPrintServer())
    {
        foreach (PrintQueue _pq in _LocalPrintServer.GetPrintQueues())
        {
            // To Find some way to determine this _pq is NOT a virtual printer
        }
    }
TNath
  • 19
  • 1
  • Did you look at the documentation, as thats what we have to do – TheGeneral Mar 06 '18 at 08:30
  • My feeling is this wont be easy to determine, and if there is some way to do it you would need to use WMI and the printer_class and probably will not be 100% reliable https://msdn.microsoft.com/en-us/library/aa394363(v=vs.85).aspx – TheGeneral Mar 06 '18 at 08:34
  • I tried to refer many blogs but I didnt find exactly what I need.The issue is I need to find the locally installed physical printers, not those which saves pages and needs user interaction for providing file name, again not the item "Fax" also. Again if any components from System.Drawing.Printing can provide me the desired result that should be okay to me. Thanks! – TNath Mar 06 '18 at 08:39

1 Answers1

0

You will need to probe the properties in Win32_Printer class

System.Management.ObjectQuery oq = new System.Management.ObjectQuery("SELECT * FROM Win32_Printer");
ManagementObjectSearcher mos = new ManagementObjectSearcher(oq);
ManagementObjectCollection moc = mos.Get();
foreach( ManagementObject mo in moc )
{

    string name = mo["Name"].ToString();
    string language = mo["DefaultLanguage"].ToString();
    MessageBox.Show(String.Format("Printer: {0} -- Language: {1}", name, language);
}

Maybe you could check the languages field for postscipt or pcl (only a guess), though you might just have to check the difference between all your printers to find an loosely indicative way.

In any case i can be fairly confident there is no way to exactly check for what you want as there is no field called virtual printer as to your specs.

TheGeneral
  • 79,002
  • 9
  • 103
  • 141
  • Thanks Michael for the response. I would research accordingly and let you update. Thanks for the insight. – TNath Mar 06 '18 at 12:02