22

How can I preview PDFs with Google Chrome in dark mode / reverse color?

By default it is white colored:

Screenshot showing question author looking at arxiv.org research archive PDF, in Google Chrome

Followed-up by my asking How can I change the grey background of the PDF preview in Google Chrome to black?.

2
  • Chrome is not part of Windows, why did you tag it Windows?
    – Mark
    Feb 22, 2020 at 6:03
  • @Mark in case of OS-dependent solution. Feb 22, 2020 at 6:06

2 Answers 2

40

The following snippet adds a div overlay to any browser tab currently displaying a PDF document.

1. Open up your browser's Dev tools then browser console.
2. Paste this JavaScript code in your browser console:
const overlay = document.createElement("div");

const css = `
    position: fixed;
    pointer-events: none;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: white;
    mix-blend-mode: difference;
    z-index: 1;
`
overlay.setAttribute("style", css);

document.body.appendChild(overlay);
3. Hit Enter

Special thanks: https://www.reddit.com/r/chrome/comments/e3txhi/comment/fem1cto

6
14

You can use the Dark Reader Google Chrome extension and used the Filter+ mode. It will work on the online PDF files, but not at the local PDF files.

Hint from Hirbot Behnam:
If you want to make it work with local files (e.g. PDFs) too, go to chrome://extensions/ and click on Details button below the extension "Dark Reader" and from there, enable Allow access to file URLs.

enter image description here

6
  • 1
    it works, thank you!
    – Lonely
    Jul 26, 2020 at 18:22
  • 7
    If you want to make it work with local files too, go to chrome://extensions/ and click on Details button below the extension and from there, enable Allow access to file URLs. Nov 12, 2020 at 15:53
  • This did not work for me when opening local pdfs
    – MaLiN2223
    Nov 30, 2020 at 21:07
  • @MaLiN2223 Correct, this doesn't work when opening local pdfs, which is quite annoying. Nov 30, 2020 at 22:16
  • 1
    This did work for me, including for local PDF when allowing access to file URLs in Chrome Extensions settings.
    – gaborous
    Mar 12 at 0:01

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.