How to turn a PDF grayscale in Ubuntu?

I have a pdf (having multiple pages) containing some colorful certificates, and need a black and white (grayscale) version of it.

Is there any way to make it grayscale with a single command, or with any simple GUI program (preferably FOSS)?

In principle, I can open all the pages separately in GIMP, make them grayscale, and rejoin, but that would take a lot of effort.

3

3 Answers

One of the ways is to use ImageMagick with some scripting.

You have to try its convert program as follows for single document:

convert -grayscale average color-in.pdf grayscale-out.pdf

More details about possible options are presented in its man-page locally by man convert or online.

Note: you may get "not authorized" message which is fixable by following this Q&A.

1

A similar question and answer is there in Stack Overflow.


Convert has the great disadvantage of converting to bitmap images, whatever you do... Try this out:

gs -sOutputFile=outfile.pdf -sDEVICE=pdfwrite \ -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray \ -dCompatibilityLevel=1.4 infile.pdf < /dev/null

You have to redirect from /dev/null because by default, gs is interactive. There is a host of options available to tune the output, you can look at the pdfwrite parameters of ghostscript.

In this method, the output pdf does not blow up in size, and also, its quality does not degrade.

2

Download GIMP and open your pdf file. It will ask for resolution. There you can enter number pixels or select pixel/in etc. Now just went to Image >> Mode >> Grayscale. That is your complete pdf file is converted to grayscale. Now Go to File >> Export As >> yourfilename.pdf and press export. Edit: If you have problem getting large size file. You can opt for following options(In toto you have to achieve minimum number of colors to reduce your file size. If you understand that you get the solution.)

Step 1: Image >> Mode >> Grayscale

Step 2: Image >> Mode >> Indexed >> Generate optimum palette(Here you will find 256 numbers of colors) >> change the Maximum number of colors to 10 or any other value that suits your file size.

Step 3: If you want to reduce the file size further. Than you can opt for this step.

Image >> Mode >> Indexed >> Generate optimum palette >> Here this time select for Use web-optimized palette.

Note even if you want small size color pdf you can skip the step 1.

The reason for large size of pdf is number of colors.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like