Install ghostscript from yout terminal : sudo apt install ghostscript
, then create file, for example pdf2gray.sh and copy paste the script bellow. Add execution access using chmod +x pdf2gray.sh
#!/bin/bash
gs \
-sOutputFile=$2 \
-sDEVICE=pdfwrite \
-sColorConversionStrategy=Gray \
-dProcessColorModel=/DeviceGray \
-dCompatibilityLevel=1.4 \