When it comes to printing then all colors in a PDF document are transformed to the native color space of the printing device. If, e.g. a text uses a black RGB color then it is transformed to an equivalent CMYK value which contains contributions from all four color channels. In particular in mass printing applications these "rich black" values are not wanted, however, and it is required to use "true black" colors which use the K channel only. This article gives some ideas how this transform can be achieved.
Rich black colors are usually created by color management systems (CMS) which are used in viewers or printing applications. The transform itself uses the ICC color profiles of the source and target device. If the source e.g. is an sRGB color space then the black is first transformed to the linear XYZ space then to the L*a*b space and then these values are used to lookup the equivalent CMYK values using the color profile of the printing device.
In order to create true black values the CMS transform must be bypassed. For simple fill and stroke colors this can be done by comparing the values of the RGB color channels. If they are equal or almost equal within a given tolerance then the value can directly be converted to a true black value. For images, however, all pixel values must be analysed first, and if every pixel is on a gray scale then the image can be transformed to true black.
If the source color space, however, is not RGB but CMYK because the colors have already been transformed by an earlier processing stage then things get more complicated. A naive approach would be to transform them into RGB and thereafter use the algorithm above. However, one get more accurate results if one computes the gray line (a line which represents all values from the black pint to the white point) within the color space and then compute the distance of the CMYK value from this gray line.
Since converting rich black colors into true black colors is not a trivial task we created a new tool to perform this. Beside of this the tool also can convert other color values to CMYK and replace specific colors within a given tolerance even supporting anti-aliased images.
Please let me know if you find this article useful.