[comp.lang.postscript] Detecting color printer

kly@sci.ccny.cuny.edu (Gregory Kozlovsky) (06/20/91)

I would like to create a Postscript file which would be printed
differently on color and black&white printers. For example, lines
which have different colors on a color printer should be drawn with
different dash patterns on black&white one. What is the correct way
to ask the printer?  I would prefer not to use level 2 features.

          Gregory

klute@tommy.informatik.uni-dortmund.de (Rainer Klute) (06/20/91)

In article <1991Jun20.053653.20412@sci.ccny.cuny.edu>,
kly@sci.ccny.cuny.edu (Gregory Kozlovsky) writes:
|> I would like to create a Postscript file which would be printed
|> differently on color and black&white printers. For example, lines
|> which have different colors on a color printer should be drawn with
|> different dash patterns on black&white one. What is the correct way
|> to ask the printer?  I would prefer not to use level 2 features.

I do it by testing whether the PostScript interpreter knows about the
setcolorscreen operator:

(This is ) print
systemdict /setcolorscreen known
{
    (a)
}
{
    (no)
}
ifelse
print

-- 
  Dipl.-Inform. Rainer Klute      klute@irb.informatik.uni-dortmund.de
  Univ. Dortmund, IRB             klute@unido.uucp, klute@unido.bitnet
  Postfach 500500         |)|/    Tel.: +49 231 755-4663
D-4600 Dortmund 50        |\|\    Fax : +49 231 755-2386

cet1@cl.cam.ac.uk (C.E. Thompson) (06/21/91)

In article <3551@laura.UUCP> klute@tommy.informatik.uni-dortmund.de (Rainer Klute) writes:
>In article <1991Jun20.053653.20412@sci.ccny.cuny.edu>,
>kly@sci.ccny.cuny.edu (Gregory Kozlovsky) writes:
>|> I would like to create a Postscript file which would be printed
>|> differently on color and black&white printers. For example, lines
>|> which have different colors on a color printer should be drawn with
>|> different dash patterns on black&white one. What is the correct way
>|> to ask the printer?  I would prefer not to use level 2 features.
>
>I do it by testing whether the PostScript interpreter knows about the
>setcolorscreen operator:
>
> ...

Unfortunately, although this may have been a good risk in the past, it
will not continue to work. All Display PostScript implementations, and
all level 2 implementations, will have 'setcolorscreen' regardless of 
whether any associated device supports multiple colours.

In fact, regardless of not wanting to use level 2 facilities, I can't
see any way of determining this information using only the operators    
defined to be in the level 2 set. For Display PostScript you could look
at the 'Colors' value in the directory returned by 'deviceinfo'.      

PPD files contain an entry *ColorDevice indicating whether the device
supports colour. If you are using a document manager that replaces   
%%BeginFeature/%%EndFeature sections from PPD files, you could make  
use of this.

Chris Thompson
JANET:    cet1@uk.ac.cam.phx
Internet: cet1%phx.cam.ac.uk@nsfnet-relay.ac.uk

kevind@pogo.WV.TEK.COM (Kevin Draz) (06/21/91)

In article <1991Jun20.053653.20412@sci.ccny.cuny.edu> kly@sci.ccny.cuny.edu (Gregory Kozlovsky) writes:
>
>I would like to create a Postscript file which would be printed
>differently on color and black&white printers. For example, lines
>which have different colors on a color printer should be drawn with
>different dash patterns on black&white one. What is the correct way
>to ask the printer?  I would prefer not to use level 2 features.
>
>          Gregory

Version 49 and later of PS have an operator in statusdict called
"processcolors" which return the number of primary colors known
to the printer at that moment.  For most printers it is 1=monochrome,
3=CMY, 4=CMYK.  This would depend, for example, on the type of transfer
ribbon loaded in a thermal-wax printer.  Although possible, I've never
seen a value other than 1, 3, or 4.

Only 49.0 and later PS versions implement color extension to level 1 PS.

Therefore:

/hascolor {
	statusdict /processcolors known
		{ statusdict /processcolors get exec 1 ne }
		{ false } ifelse
} def

Defines a procedure "hascolor" which returns a boolean "true" if more than
one color is known to the printer, i.e. CMY or CMYK, and false if the PS 
version is too early for color, or is a late version of a monochrome device.


-- 
----
kevind@pogo.wv.tek.com  | For most software publishers, quality is job 1.01.
Tektronix Color Printers|                            -- MacWeek Magazine