Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invert document colors (night mode) #8253

Closed
PeterNerlich opened this issue Apr 7, 2017 · 4 comments
Closed

Invert document colors (night mode) #8253

PeterNerlich opened this issue Apr 7, 2017 · 4 comments

Comments

@PeterNerlich
Copy link

[Feature Request]

Configuration:

  • Web browser and its version: Chromium 57.0.2987.98
  • Operating system and its version: Elementary OS Loki (elementary 0.4, 64-bit)
  • PDF.js version: 1.6.293
  • Is an extension: Yes

The systems default PDF viewer has this handy feature inverting the colors of the document, which I use all the time as it is considerably more convenient, especially at night. To my understanding, this should be very easy to implement, as it required no more than applying filter: invert(); to the .pdfViewer .page and maybe inverting the border image again.
It would also be handy to have the keyboard shortcut [Ctrl] + [I] for it, as it is used in the systems viewer.

@Snuffleupagus
Copy link
Collaborator

Closing as duplicate of issue #2071 (and #2163).

@alexchandel
Copy link

Please re-open. Night mode refers specifically to @media (prefers-color-scheme: dark) { ... } CSS, which is not the same as the user generically changing text/background colors.

@silgon
Copy link

silgon commented Apr 2, 2020

Please re-open. Something like [Ctrl] + [I] would be really neat.

@let-def
Copy link

let-def commented Jul 18, 2023

Thanks for the CSS rule. Since it seems this feature is not going to make it to PDF.js anytime soon, I saved it as a bookmarklet. If anybody is interested:

javascript:(function(f){if(f.cssRules.length)f.deleteRule(0);else f.insertRule('.pdfViewer .page{filter:invert();}');})(window['_pdfsty']=window['_pdfsty']||document.head.appendChild(document.createElement('style')).sheet))

It creates a new stylesheet element with the right rule, and toggle it (removing or re-adding it) if applied again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants