Search code examples
rgbghostscriptcmyk

How to force Ghostscript to convert PDF to monochrome bitmap using CMYK colors instead of RGB?


I have a PDF file containing black text specified with CMYK color of 0,0,0,100. When I convert this to "bmpmono" using ghostscript, it interprets this as not 100% black. I discovered that CMYK 0,0,0,100 actually converts to RGB of around 36,32,33 and not 0,0,0 as I had expected (but is explained here).

I believe what's happening is ghostscript is converting the CMYK to RGB and then to monochrome, so I end up with non-fully-black text. Is there a way to force ghostscript to stick with the CMYK and directly convert to monochrome to keep the 100% black?

Here is my command:

gswin64c.exe -dNOPAUSE -sDEVICE=bmpmono -dBATCH -dDEVICERESOLUTION=200 -sOutputFile=testout.bmp -f source.pdf

Solution

  • GS will do a conversion from CMYK to Gray through the defined ICC profiles. There are darker CMYK values that exist (for GS's defined CMYK source profile -- and for most) compared to a CMYK value of [0 0 0 100] So, [0 0 0 100] ends up being mapped to something that is not the darkest in the Gray output space.

    A couple options would be to try

    -dUseFastColor

    which will avoid the use of ICC profiles for color mapping and use old school 255-X with UCR/BG type mappings.

    Another option is to use

    -dBlackText=true

    This will force all text components (except for Type 3 fonts) to be filled (or stroked) with a gray value of 0 which should map to 0 for the bmpmono device.