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.
231k 71 71 gold badges 622 622 silver badges 603 603 bronze badges asked Jul 16, 2012 at 20:39 221 1 1 gold badge 2 2 silver badges 3 3 bronze badgesFunnily 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
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.
answered Jul 16, 2012 at 21:30 AlwaysLearning AlwaysLearning 1,387 9 9 silver badges 13 13 bronze badgesI'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.
Commented Jul 16, 2012 at 22:38Using 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.
Commented Jun 13, 2017 at 9:57None 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
#!/bin/bash pdftk "$1" output - uncompress | \ awk ' /^1 1 1 / < sub(/1 1 1 /,"0 0 0 ",$0); print; next; >/^0 0 0 / < sub(/0 0 0 /,"1 1 1 ",$0); print; next; >< print >' | \ pdftk - output "$" 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.
answered Oct 27, 2017 at 4:54 141 2 2 bronze badgesThere 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 " 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 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 some sort of online PDF inverter which will probably just do this for you. (Edit: There used to be no such websites. After seeing this thread, I made one and ran it for a while, but then after a few other websites popped up offering the same service I closed mine.)