Counting and reducing colour pages in PDF documents
When having documents printed by a professional printer, costs per page tend to be higher for pages including colour than for pages which are grayscale or black-and-white (five times higher in my recent experience). This is fair enough and unavoidable, though if the colour pages are counted and selected automatically, you may pay for more colour pages than you anticipated. The reason for this is that pages which look grayscale or black-and-white, particularly those with figures, may be coded and recognised as colour.
The following details my approach to counting and finding all ‘colour’ pages, and ensuring pages which really should be grayscale are detected as such. It requires Ghostscript (gs) and should work in the command line interfaces of Mac and *nix systems.
Counting and finding colour pages
Some online print services or copy shops require you to specify the number of colour and black-and-white or grayscale pages yourself, so then the following will save you some time or confirm your manual counting.
To merely find the colour pages, go through the full output (or write a script that tells you the corresponding page numbers):
which gives you an output similar to
in a case where the second page contains colour. It shows the relative ‘ink coverage’ of all colours, in this case of cyan, magenta, yellow, and black (CMYK).
Converting to grayscale
When a page in a document, or a figure embedded in this page, looks grayscale but is identified as a colour page, the page or figure should be converted to a different colourmap.
Make sure the input and output name aren’t the same, or you get a blank document.
I have also tried to save a PDF in Mac OS X’s preview, with a Black & White or Gray Tone Quartz Filter, but this didn’t do the trick for me. The above works like a charm though.
Using ImageMagick, the result gets rasterised and of very poor quality if you zoom in a bit. (Almost sent it off like this!) However, for changing the colour map of raster images the following works fine:
Here, a different output file name is not necessary: the file can be edited in-place.
After successfully converting pages or figures within a document, the aforementioned colour page counting method should return a lower number, saving you some unnecessary colour printing costs.