3

Is there a freely available (preferably open source) tool or library for PDF conversion to black and white?

Some customers want to print generated PDF documents in B&W to save toner. Unfortunately I cannot generate PDF in B&W directly, since we are merging two PDF pages together, one being official not available in B&W.

Update: To be more specific, I am looking for automatic solution, i.e. tool that is callable from a program.

Viliam
  • 4,304
  • 3
  • 25
  • 30
  • 1
    Do you really mean 'black and white'? Or do you mean 'grayscale'? – Kurt Pfeifle Dec 21 '11 at 12:32
  • 1
    @pipitas Yes, black and white – Viliam Feb 14 '12 at 15:32
  • You don't seem to know that each printer using only black toner can print many levels of grayscale. So a grayscale PDF (like created by command from 'Ghostscript' answer) is certainly good to go for your customer... – Kurt Pfeifle Aug 19 '12 at 19:08
  • @Villiam: "Pathetic" is in the eyes of the observer only. Congratulations! You're one of those who can "see". -- I **know** how to solve such problems reported by customers, and I get paid for this. Your original problem description didn't mention the dark red background. To find a really well working solution for such a problem one needs to see a sample PDF exhibiting it. Because converting to "black-and-white-without-any-grayscale" could well result turning your "dark red" into black and then you're still screwed... – Kurt Pfeifle Sep 20 '12 at 20:13

3 Answers3

23

Having seen Viliam's insisting on wanting "Black and White", not "Grayscale" I'm still offering this solution to convert PDF files to grayscale. Because I think that would perfectly fullfil the requirement to "save color toner" and make use of black toner only.

Use Ghostscript (the most recently released version is 9.05) with this command:

 gs \
   -o black+white.pdf \
   -sDEVICE=pdfwrite \
   -dPDFSETTINGS=/prepress \
   -sColorConversionStrategy=Gray \
   -sColorConversionStrategyForImages=Gray \
   -sProcessColorModel=DeviceGray \
   -dCompatibilityLevel=1.4 \
    /path/to/input.pdf

On Windows, use gswin32c.exe or gswin64c.exe instead of gs. Ghostscript meets Viliam's request for:

  • freely available
  • Open Source
  • callable from a program

and it does the job.


Update

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

  1. your Ghostscript probably is a newer release from the 9.x version series, and
  2. your source PDF likely uses an embedded ICC color profile

In this case add -dOverrideICC to the command line and see if it changes the result as desired.

Kurt Pfeifle
  • 78,224
  • 20
  • 220
  • 319
  • 2
    Thanks, that answer was useful to me :). – Bruno Le Floch Aug 01 '12 at 13:50
  • Also was helpful to me. Here is the command line I used in windows: "C:\Program Files\gs\gs9.05\bin\gswin64.exe" -o top_black.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sColorConversionStrategy=Gray -sColorConversionStrategyForImages=Gray -sProcessColorModel=DeviceGray -dCompatibilityLevel=1.4 c:\path\to\inputFile.pdf – Ari Sep 27 '12 at 19:13
  • I tried this with gs 9.10 on Ubuntu, got "Unable to convert color space to Gray, reverting strategy to LeaveColorUnchanged.", discovered answer http://stackoverflow.com/a/20133915/223837, and that solved this message. I don't know which of the different flags actually makes a difference. – MarnixKlooster ReinstateMonica Nov 12 '14 at 21:01
  • Recent Ghostscript versions have extended their support to handle ICC profiles. So if your PDF had an ICC color profile embedded this might have prevent Ghostscript from following your conversion orders. In these cases, adding a **`-dOverrideICC`** parameter would enforce your desired color conversion. – Kurt Pfeifle Nov 13 '14 at 11:24
  • Devs say ([1](https://bugs.ghostscript.com/show_bug.cgi?id=700819#c1),[2](https://bugs.ghostscript.com/show_bug.cgi?id=693716#c4),[3](https://ghostscript.com/irclogs/2012/11/21.html),[4](https://stackoverflow.com/a/36337225/1032586)) that there's no `-sColorConversionStrategyForImages` switch. – Igor Mar 19 '19 at 22:11
3

Try this website,

http://online.puzzleflow.com/process/all2gray

It worked for me.

Update

It has been made a payed website

Remus_C
  • 15
  • 7
Mona
  • 5,160
  • 3
  • 25
  • 33
2

With PrimoPDF (http://www.primopdf.com/index.aspx) you should be able to set to generate a "Black & White" pdf.

"Printing Preferences" -> "Paper/Quality" tab, then you can choose between "Black & White" and "Color.

Regards
Thomas

Thomas
  • 154
  • 6
  • Looks good, thanks. But I was hoping to get something I can call automatically from the application. I've updated the question now. – Viliam Feb 19 '10 at 16:37
  • This didn't work for me. I selected "Black and White" print paper but the resulting PDF still contained color. – Gili Oct 31 '10 at 17:36