(Useful for PDF "darkmode".)
-
Start a Docker container with a bind volume mount to the current directory:
docker run --rm -it -v "$PWD:/mnt" alpine
-
Install Ghostscript within the container:
apk add --no-cache ghostscript
-
Invert colors on the desired PDF:
gs -o /mnt/input.pdf \ -sDEVICE=pdfwrite \ -c '{1 exch sub}{1 exch sub}{1 exch sub}{1 exch sub} setcolortransfer' \ -f /mnt/output.pdf
NOTE: Not all PDF viewers will respect this method of inverting PDF colors. See reference below for more information.
Inspired by: https://superuser.com/a/1366655