Re:
On Nov 19, 2007, at 8:39 AM, Daniel Birns wrote:
On Nov 19, 2007, at 1:56 AM, David Duncan wrote:
On Nov 16, 2007, at 7:11 PM, Daniel Birns wrote:
Hi,
Could someone please direct me to documentation for an API to
find out the color capabilities of an attached printer?
I can find the name, resolution sets and print formats supported
and all that in the PMPrint api, but there's nothing in there
about color (or what was there is now obsolete). Where has it
gone?
What specific information are you looking for in relation to color?
Is it a color printer? b&w? greyscale? That's all...
I think the best you can do at this point in time is to examine the
PPD file for the *ColorDevice keyword. That will tell you whether a
printer is a ColorDevice (True) or not Color (False). It won't tell
you whether a color printer is in "grayscale mode" for a given
print job or whether a non-Color printer can actually produce gray
scale. There is a PPD keyword ContoneOnly but I don't believe it is
reliably used by creators of PPD files..
If this is code in an application, (not a printing dialog extension
or CUPS filter) you can get the PPD file for a given printer using
PMPrinterCopyDescriptionURL. In any case, you can use the cups PPD
API to look at this value.
In principle this should work (but I've not compiled and tested it):
bool isColor = true; // a conservative default
ppd_file_t ppd = ppdOpenFile(pathToPPD);
if(ppd){
ppd_attr_t *attr = ppdFindAttr(ppd, "ColorDevice", NULL);
if(attr != NULL && attr->value != NULL)
isColor = ppd->color_device;
ppdClose(ppd);
}
Note that the reason the above code explicitly checks for the
existence of the ColorDevice keyword is that the default for the
ppd->color_device is false so if a PPD file doesn't contain the
keyword, it is labelled as a non-color device. There are many PPD
files that don't contain the keyword yet are color printers. Hence
I suggest the check above.
David