Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: color capability



Hi David,

This sample code worked perfectly, right out of the box. It told me my B&W printer is not color and the color one is, unlike the deprecated call. Thanks a lot!

-Daniel
On Nov 28, 2007, at 3:52 PM, David Gelphman wrote:

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

_______________________________________________ Do not post admin requests to the list. They will be ignored. Printing mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/printing/email@hidden

This email sent to email@hidden
References: 
 >color capability (From: Daniel Birns <email@hidden>)
 >Re: color capability (From: David Duncan <email@hidden>)
 >Re: color capability (From: Daniel Birns <email@hidden>)
 >Re: color capability (From: David Gelphman <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.