I have an existing PDF with a totally black background and all text is white.

Is there a way to get the text to print black and the black background to not print at all?

I have Bluebeam and Adobe PDF.


Funnily enough there are "legitimate" use cases for this, notably people with low vision. Acrobat and other readers can override colors for display (eg Ctrl-I in Evince and via the Accessibility menu in Acrobat Reader X) but strangely not for printing. What you can do, though, is use GhostScript's pdf2ps converter (or a fake PS printer driver that just writes the file) to get a postscript file, then edit the file by putting

{1 exch sub} settransfer 

as the first line in the file and then printing that PostScript file. That way you get a more faithful rendering of the doc than you would if you converted the PDF to an image and inverted that.

| improve this answer | |
  • 1
    I've done something like this (on Windows) by installing a PostScript printer driver and then telling it to print to file to capture the output. The same concept should work on other OSs. It should be noted that PostScript files are just text files that can be edited with most text editors. – martineau Jul 16 '12 at 22:38
  • Using a combination of pdf2ps and ps2pdf I can be able to export the original pdf into an inverted pdf file. I'm just curious on what the proposed line do and if it is possible to "revert" back to the original colors. – tigerjack89 Jun 13 '17 at 9:57

There is an easy way, and a technical way.

The technical way is that if you have Ghostscript installed and have its .../bin folder added to your PATH, you should just be able to invert the colours of your PDF by calling something resembling the following from the command-line:

gswin64 -o C:/outputfile.pdf -sDEVICE=pdfwrite -c "{1 exch sub}{1 exch sub}{1 exch sub}{1 exch sub} setcolortransfer" -f C:/inputfile.pdf

Note that gswin64 (located in the .../bin folder) might be called gswin32 if you downloaded the 32-bit version, or something else entirely if you're on a *nix system instead of Windows, and that you should obviously replace C:/outputfile.pdf and C:/inputfile.pdf with the actual paths of your input file and intended output file location. Also take care that in my experience there can sometimes be a bit of trouble if you have spaces in your path directories, even if you put quotation marks around them.

It's also worth noting that iirc some versions of Ghostscript might fail on this unless you put the {1 exch sub}{1 exch sub}{1 exch sub}{1 exch sub} setcolortransfer line in a separate .ps file and just add the .ps file to your command.

(This is really just a more fleshed-out version of Mateen Ulhaq's answer above)

The easy way is that if you can't be bothered doing any of the above, you can use the website InvertPDF.com that will do all of this (plus a little more) for you. This is my own website, and I stumbled upon this thread while I was trying to build it. I sure hope this answer makes it easier for the next person trying to achieve a similar thing, or making their own offline script.

| improve this answer | |

According to this page, you may be able to accomplish it with ImageMagick. However, the PDF will be converted to images before it is inverted. If the quality isn't sufficient because of this, you should be able to adjust the DPI number.

convert -density 300 -negate "input.pdf[1-999]" output.pdf

Replace 300 with your desired DPI and 1-999 with your desired page range.

NOTE: This command is for an older version of ImageMagick and you will need to ensure that legacy utilities are installed.

Legacy Utilities

| improve this answer | |
  • @fixer1234 Thanks for bringing this to my attention. I have added a link to that page on the Internet Archive. – bdr9 Nov 17 '15 at 19:55

In Acrobat Reader X

Edit->Preferences->accessibility Select: Replace document colors Select: Custom color

Set remaining options according to personal preference.

Note: This does not change the document, just your view and they way it is printed.

| improve this answer | |
  • Does not print differently than the original AFAICT – mike65535 Jun 25 '18 at 19:27

None of the previously posted solutions worked for me so I wrote this simple bash script. It depends on pdftk and awk. Just copy the code into a file and make it executable. Then run it like:

$ /path/to/this_script.sh /path/to/mypdf.pdf

The script:

pdftk "$1" output - uncompress | \                                               
awk '                                                                            
  /^1 1 1 / {                                                                    
    sub(/1 1 1 /,"0 0 0 ",$0);                                                   

  /^0 0 0 / {                                                                    
    sub(/0 0 0 /,"1 1 1 ",$0);                                                   

  { print }' | \                                                                 
pdftk - output "${1/%.pdf/_inverted.pdf}" compress

This script works for me but your mileage may vary. In particular sometimes the colors are listed in the form 1.000 1.000 1.000 instead of 1 1 1. The script can easily be modified as needed. If desired, additional color conversions could be added as well.

| improve this answer | |

If you want a more pleasing greyscale, and are OK with converting your document to images, throw this into a .bat file and then simply drag your PDF onto the .bat file.

"C:\Program Files\gs\gs9.20\bin\gswin64c" -o inverted.pdf -sDEVICE=pdfwrite -c "{1 exch sub}{1 exch sub}{1 exch sub}{1 exch sub} setcolortransfer" -f %1
convert -brightness-contrast 3,-18 -compress lzw  -density 300 -colorspace Gray inverted.pdf output.pdf

Requires Ghostscript to be installed for the first command (please specify correct path). Requires ImageMagick with legacy utilities to be installed for the second command.

| improve this answer | |

Many had suggested using the Edit->Preference->Accessibility method but sadly it did not work for me. After testing and playing around PDF setting, I managed to get what I wanted!

  • Go to Print (Ctrl + P)
  • Click Advanced Settings
  • Check Settings: Custom
  • Click on Output from left panel
  • Under Color: select Composite Gray
  • Check the Negate box
  • Click OK

This should do the trick!

Important Note!
I would suggest printing this file to a PDF than directly. Especially if you intend to print multiple pages in one page as it will result in the whitespace turning black too!

Lastly, if you are going to print the document as another PDF, under Page Sizing & Handling , click on Fit and check both the boxes - "Choose paper size when needed" and Use custom paper size when needed. (To avoid unwanted whitespace)

Hope this help!

| improve this answer | |
  • This is specific to your printer driver – Mark Jeronimus Jun 18 '18 at 14:06

I've tried many of the answers here, and none have been adequate for me. The top answer simply didn't work, and most other solutions converted each page of the PDF into a raster image, inflating the size and decreasing the quality.

For these reasons, I decided to create a solution of my own, which can be downloaded from github here. It's a relatively simple Java program built upon a fork of pdfbox v2.0.19. (The fork exists simply to allow access to two otherwise private fields/methods.) It's licensed under the highly nonrestrictive MIT license.

Using the program is very simple. Simply enter the following command in the same directory as PDFInverter.jar:

java -jar PDFInverter.jar input_file.jar output_file.jar

This will invert all objects, including raster images, in the PDF, while maintaining the lossless nature of text and vector elements in the file. Additionally, you can supply a custom background color by specifying a CSS color string as a 3rd parameter like so:

java -jar PDFInverter.jar input_file.jar output_file.jar #7f7f7f

If you would like to leave raster images contained in the file untouched, you can enter "false" as the 4th parameter to disable the feature:

java -jar PDFInverter.jar input_file.jar output_file.jar #7f7f7f false


  • There are certain uncommon features which the program does not support. Primarily, it doesn't support the use of the Pattern color space. (See the PDF specification § and §8.7)
  • The program converts all colors to the DeviceRGB color space (§, meaning there might be a loss of gamut if the corresponding color was defined in a different color space.

Disclaimer: This is a project which I have personally developed. While I have nothing to gain from your use of the program, I still feel it is important to make it clear that I am the one who developed the program, and might be biased towards its use or otherwise.

| improve this answer | |

Using ImageMagick worked for me, although the outputfile is about 50 times larger than the input one.

convert -density 300 -negate input_file.pdf output_file.pdf
| improve this answer | |
  • The command line (in luinux) was : convert -density 300 -negate input_file.pdf output_file.pdf – Catchaca Jan 19 '16 at 22:06

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.