Determine if printing in color

I’ve searched everywhere I know and couldn’t find anything relevant.

When using a printer dialog for the user to select a printer and change any available settings, how can I determine the printout will be in color (color capable printer not set to grayscale)? I print a chart with legend that uses red for some of the items (text and graphics), but this doesn’t translate so well to a grayscale output. So I want to set the red items to a different color that shows up better when printing in grayscale. But I can’t figure out how to determine that.

I need this for both OS X and Windows.

Funny: I do not think at that !

I just add a MenuItem I called Print in Color (or so) ! Without asking question.

OSX I have no idea about, sorry.

In windows, you would normally retain the handle to the opened printer then use that in conjunction with the handle to the created device context to find the spooled job that is being created while you do your graphics drawing. You would then get the pJob > JOB_INFO_2 > DEVMODE > dmColor value of the job which should indicate DMCOLOR_COLOR or DMCOLOR_MONOCHROME of that specific job.

But as (I think) Xojo hides away the printer handle (g.handle(1) only gives the device handle), its not possible without doing the whole print process yourself using declares.

Can’t you use a darker red that shows up better in B&W? Much easier :wink:

take a look at the printersetupstring that is returned from the printdialog
then search for the “ColorModel” tag. one has the value “Mono” and the other has the value “RGB”
note that this value may depend from the printer driver (and so the model of printer you’re using)

[quote=365936:@Jean-Yves Pochez]take a look at the printersetupstring that is returned from the printdialog
then search for the “ColorModel” tag. one has the value “Mono” and the other has the value “RGB”
note that this value may depend from the printer driver (and so the model of printer you’re using)[/quote]
I actually played around with this, but couldn’t make sense of the setupstring. But I did find that a non-color printer didn’t have any “color” text in the setupstring.

What kind of format is the setupstring in? Looks like it contains XML, but there’s lots of unprintable characters in it also.

you don’t need the exact meaning of each tag or unprintable character in that string.
just record the two strings when in color or not, point out the differences and voil.
you only need to check if it contains “color” or not ?

the setup string is some xml with control characters as separators, but I also don’t have any description of it.
may be something in the apple documentation ? it definitely looks like xml.

for my printer (an epson wf5620) I did find that the “ColorModel” tag was in both strings
and that the value next to it was different (rgb vs mono)
so it definitely depends on the printer.

First I need to determine if the printer is capable of printing color at all, then if color capable, whether it’s actually printing in color.

[quote=365960:@Jean-Yves Pochez]for my printer (en epson wf5620) I did find that the “ColorModel” tag was in both strings
and that the value next to it was different (rgb vs mono)
so it definitely depends on the printer.[/quote]
For my printer, there are two “ColorModel” tags. The first one doesn’t contain anything about rgb vs. mono. The second one does. So it looks like there could be a lot of trial and error trying to accommodate various printers.

You can never be sure. Lot’s of printservers like PaperCut have a convert to grayscale function. You setupstring will mark the printer as color, while it spits out grayscale only.

on macos you can get much infos about the printer capabilities with the command line “cups” command.
don’t know for windows.

Yeah, this doesn’t look too promising, especially for cross-platform. I have filed a feature request and hope that Xojo can provide something. <https://xojo.com/issue/50930>

I made a software once for this.
We had a list with about10 keys and values combinations for each mino vs. color.
It depends on Mac on printer driver.

For Windows since the move to direct draw you can’t get the real handle any more.