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.

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.

Answered By: N0rbert

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.

Answered By: Vincent Fourmond

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.
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.

Answered By: Ajay

In my case I am keeping signed document scans in color, but need reprint it without gray noice. For this case works well

convert -density 300 -threshold 75% input.pdf output.pdf

(based on the answer)

Range between 50%-75% works fine in circumstances when you have color scan PDF (text as image) with original resolution 300dpi.

In case of text saved as PDF (not image) you will get huge increasing of output file size.

Answered By: x'ES
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.