I'm searching for a linux command-line utility/script capable of removing colors in a PDF. The output of the utility should be the same PDF, but in grayscale.
Does anyone know how to do this?
Thanks
You can use Ghostscript:
gswin32c ^
-o grayscale.pdf ^
-sDEVICE=pdfwrite ^
-sColorConversionStrategy=Gray ^
-sProcessColorModel=DeviceGray ^
-dCompatibilityLevel=1.4 ^
c:/path/to/input.pdf
(example is for Windows; on Linux use gs instead of gswin32c.exe and \ as a line continuation mark instead of ^).
If color conversion does not work as desired and if you see a message like "Unable to convert color space to Gray, reverting strategy to LeaveColorUnchanged" then...
In this case add -dOverrideICC to the command line and see if it changes the result as desired.
Also, the original answer contained a typo:
-sProcessColorModel=/DeviceGray-sProcessColorModel=DeviceGray (no forward slash))If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With