I could not find out which procedure for color selection is used in the PDFs I am dealing with. This is why I convert to grayscale PostScript first:
gs -o gray.ps -sDEVICE=ps2write -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray -dCompatibilityLevel=1.4 -f colored.pdf
As the PDFs I struggle to print may contain confidential information which is cleverly "redacted" by having the color set to white, I need to employ some sort of thresholding. This is what I came up with:
gs -o thresholded.pdf -sDEVICE=pdfwrite -c "/osetgray {setgray} bind def /setgray {0.5 lt {0} {1} ifelse osetgray} def" -f gray.ps
For those (like me) unfamiliar with PostScript's stack programming style, this re-defines setgray as:
setgray(value) {
original_setgray(value < 0.5 ? 0 : 1)
}
To verify the feasibility of this approach, you can create a simple PostScript file using enscript:
printf 'Dark \x00color{0.9 0.9 0.9} Light\n' | enscript --escapes --no-header -o colored.ps
Then proceed to use both commands as given above.
The gray.ps produced by Ghostscript's ps2write will contain the line /G/setgray load def. This provides /G as an alias to /setgray. Somewhere later the actual typesetting happens (irrelevant lines omitted):
(Dark )Tj
0.898 G
( Light)Tj
Only in these circumstances the thresholded.pdf will show "Dark" as fully black and "Light" as fully white.