Convert a PDF to greyscale on the command line in FLOSS?

I have a colour PDF file, and I'm going to print it out and then photocopy it in black and white. I'd like to know what it's like in B&W before photocopying it. Is it possible to 'greyscale' a PDF on the command line using free software? I'm using Ubuntu 9.10.


ImageMagick can do this.

convert -colorspace GRAY color.pdf gray.pdf

via this email


Better:

gs \
 -sOutputFile=output.pdf \
 -sDEVICE=pdfwrite \
 -sColorConversionStrategy=Gray \
 -dProcessColorModel=/DeviceGray \
 -dCompatibilityLevel=1.4 \
 -dNOPAUSE \
 -dBATCH \
 input.pdf

Here’s a little script which in addition to the grayscale conversion can concatenate multiple input files. To use the script, put the following lines in a file, e.g. "convert2gray.sh"

#!/bin/bash
gs -sOutputFile=converted.pdf -sDEVICE=pdfwrite -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray -dCompatibiltyLevel=1.4 -dNOPAUSE -dBATCH $@

and make it executable

chmod +x convert2gray.sh

Then

./convert2gray.sh input1.pdf input2.pdf … lastinput.pdf

will produce a single PDF "converted.pdf", which contains all pages from the input files converted to grayscale.

I had to print out mutliple files all in grayscale and found this the easiest way, since you can print out everything after inpection with one command.