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.
{setcolor}rather than{/setcolor}since PostScript uses no slash when procedures are called during bind. Other than that: Great answer – thank you. – Hermann Aug 17 '20 at 17:21{setcolor}or{/setcolor}as per Hermann's comment above. – XavierStuvw Mar 06 '21 at 17:44gs ... -c "/setrgbcolor{0 ...still works, however. – 0range Dec 28 '21 at 19:27{setcolor}nor{/setcolor}worked for me. – Geremia Jul 24 '22 at 22:45