I had to modify the solution suggested by Surge (above) a little bit for my file:
Step 1: Convert the coloured.pdf to coloured.ps
gswin64c -dNOPAUSE -dBATCH -sDEVICE=ps2write -sOutputFile=coloured.ps coloured.pdf
Step 2: Convert the coloured.ps to blackandwhite.pdf
gswin64c ^
-dBATCH -dNOPAUSE -q ^
-sOutputFile=blackandwhite.pdf ^
-sDEVICE=pdfwrite ^
-c "/osetrgbcolor {setrgbcolor} bind def /setrgbcolor {pop pop pop 0 0 0 osetrgbcolor} def" ^
-f coloured.ps
I did not have any success with setcolor
operator as suggested by Surge. So I decided to play with other operators that can set colour is postscript like setgray
, setrgbcolor
, setcmykcolor
, etc.
What I understand is that code in quotes following -c
switch is postscript. It tells to bind
the original definition of setrgbcolor
with a new custom operator called osetrgbcolor
. Now define a new instance setrgbcolor
that pops the 3 inputs expected by original setrgbcolor
and replace them with 0 0 0
i.e. red=0 green=0 blue=0. Thus 0 0 0
is passed to the operator osetrgbcolor
custom defined earlier
PS1: The above code was implemented in windows command prompt
PS2: I was a total stranger to Postscript coding. I got a jumpstart from youtuber "John's Basement" in the video series Postscript Tutorial. I referred Adobe's Postscript Language Reference to understand the operator setrgbcolor
and operands that it accepted.