I have a 65-page PDF file that has text in a dark grey. (Actual text, not a picture/image of text.) Printing on my B/W printer, the text gets all blurry, because the printer is trying to make it less than black. I can solve this problem page-per-page by importing the pages to inkscape, selecting all paths, clicking on "Black", which converts all colours including the greytones to pure black, and exporting back to PDF.

Is there a way to do these steps in inkscape in the command line (for batch processing)?

Is there a way to achieve the same result (convert pdf to black and white, 1-bit greyscale) without inkscape?


Edit. There are similar questions on Unix.SE and on superuser, which use Ghostscript. However, these only convert the files to greyscale via the option -sColorConversionStrategy=Gray. The option -sColorConversionStrategy=/Mono results in the error Unrecoverable error: rangecheck in .putdeviceprops. Since my file is greyscale already, these don't solve my problem.

  • 1
    Would it necessarily have to be an inkscape command or are other PDF conversion tools also okay? (I don't know how to do it, I'm just trying to improve the question) – Byte Commander Jan 31 '16 at 13:35
  • @ByteCommander Other PDF conversion tools would be okay as well. – Earthliŋ Jan 31 '16 at 13:42
  • Your pdf file, is it textual or image (i.o.w. is the text selectable or not)? – Jacob Vlijm Jan 31 '16 at 20:39
  • @JacobVlijm It's text, not an image. (It contains a couple of figures, which I don't need to convert to B/W. I care primarily about the readability of the text.) – Earthliŋ Jan 31 '16 at 21:09
up vote 0 down vote accepted

Adapting this answer over on SuperUser, this can be achieved by converting the PDF to PostScript and back using a redefined setrgbcolor command:

gs -o <output-file.pdf> -sDEVICE=pdfwrite \
-c "/osetrgbcolor {/setrgbcolor} bind def /setrgbcolor {pop [0 0 0] osetrgbcolor} def" \
-f <input-file.ps>

I have written a shell script to convert any pdf to monochrome i.e. to pure black and white. Please check it out and let me know if you face any problem.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.