DEV Community

Aditya DS
Aditya DS

Posted on

Browser hacks for Dark Mode in PDFs! πŸ¦‰

Dear dark mode lovers,
In this article I present a few hacks to view PDFs in dark mode on any browser! πŸ”₯

To get started, open any PDF in your favorite browser. Then open the dev tools by using the shortcut ctrl + shift + I or f12 and run one of the following in the console based on your browser:

New Microsoft Edge/Google Chrome/Brave/Opera

document.embeds[0].style.filter = 'invert(0.95)';
Enter fullscreen mode Exit fullscreen mode

Firefox

document.getElementById('viewerContainer').style.filter = 'invert(0.95)';
Enter fullscreen mode Exit fullscreen mode

This is the original image:
Original Image

Here is the result after running the script:
Dark Mode

πŸ’‘ You can change 0.95 to any number between 0 and 1.

If you found this useful, like the post and share it with your friends!
Thanks!

Top comments (2)

Collapse
 
suecarrera profile image
SueCarrera

When you open a PDF in Windows, select β€œView” and then opt for β€œNight Mode”. The change will be instantaneous. If, however, the black background doesn't seem to go well with certain images, you can use the Color Mode option. It's within the same menu and allows you to switch between four shades of background color . totka for husband wife relation

Collapse
 
anayallen profile image
AnayAllen

How do I make PDF darker in Chrome?
how to win the heart of a Capricorn man