views:

71

answers:

1

Is there a way to determine in .Net (or WMI) if a print driver will print to PCL or PostScript or XPS format when printing to a file?

A: 

You should be able to gather this information via WMI. Win32_Printer.DefaultLanguage is suppose to return this value. If I recall from trying this in the past though, many printer drivers don't return a value.

Check here: http://msdn.microsoft.com/en-us/library/aa394363%28VS.85%29.aspx

Somthing like this 'should' do the trick:

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);
}

This will return a UInt16, check the link for the translation of 'Default Language' to the English term ie: PCL, Postscript, HPGL etc.

Can I ask why you are trying to determine before hand what the output will be? If it's a print to file process I'd simply look at the output and determine what it is. Most newer print drivers will insert a PJL statement at the top of the job like this

@PJL ENTER LANUGAGE = "PCL"

Or simply look at the code itself for telltale indicators such as the for PCL or %PS for Postscript etc.

Douglas Anderson