I have got a PDF document containing a red font which I want to replace by a black font.

I tried the following command according to this answer:

convert -density 300 doc.pdf -fill black -opaque "#e1342d" -fuzz 60% output.pdf

I received the specific color by selecting a pixel's color from the following screenshot I took:

Screenshot of my document's font color (→ jsFiddle containing the original image)

Unfortunately, the document is still the same after converting. I think I misused the -fuzz parameter.

The distance can be in absolute intensity units or, by appending % as a percentage of the maximum possible intensity (255, 65535, or 4294967295).
ImageMagick command-line documentation

I've tried 0%, 10%, 20%, ... 100%, but none worked.

I wanted to verify that Imagick actually loads and converts the PDF:

convert -density 300 doc.pdf -fill black +opaque red output.pdf

Funnily enough, this outputs a completely white PDF (note that the page count was preserved).
The command below outputs a completely yellow PDF.

convert -density 300 doc.pdf -fill blue +opaque blue output.pdf

My system:

  • Ubuntu 13.10 64-bit
  • ImageMagick 6.7.7-10 2013-09-10 Q16
  • Ghostscript 9.10
  • Please always include your OS. Solutions very often depend on the Operating System being used. Are you using Windows, Linux, Unix, OSX, BSD? Which version? – terdon Nov 15 '13 at 16:51
  • @terdon I am sorry for not having included it. I updated my question. – ComFreek Nov 15 '13 at 16:59

I achieved the correct result with a slightly different command:

convert -density 300 input.pdf -fuzz 55% -fill black -opaque "#e1342d" out.pdf

tested on Windows with ImageMagick 6.4.4 2008-09-27 Q16

| improve this answer | |
  • I've quickly created another test document using Office 2013 and #e1342 as the font color. Your command works perfectly with this file, but unfortunately not with my original document. Do you have any ideas as to why there may be differences? – ComFreek Nov 15 '13 at 17:10
  • My solution: I supposed some differences in the file format of my original PDF, therefore I tried converting it (the PDF) to another PDF (essentially rewriting) using online2pdf.com. Converting the font color of the rewritten PDF with your command worked beautifully. – ComFreek Nov 15 '13 at 17:29

Your Answer

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

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