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?
相关问题
- Generic Generics in Managed C++
- How to Debug/Register a Permanent WMI Event Which
- 'System.Threading.ThreadAbortException' in
- Bulk update SQL Server C#
- Should I use static function in c# where many call
If your target OS is Windows, one more way is to do some logic on the driver and the print queue. You can use WMI/.NET APIs to get the driver DLL name. If it is unidrv.dll then the driver is a PCL driver and if it is pscript.dll then it is a PS driver. Of course, this is for drivers based on the MS Unidrv/PScript driver framework but you will find that a large majority of your installed based drivers are based on this framework.
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:
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.