-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Unable to change the text and background colors. #2071
Comments
Is there a CSS workaround for this? |
This is an important feature and accessibility option. Worse still, currently some font effects will obey Firefox's html user font colors, leading to unreadable text. |
Any new updates on this? I would thrilled if this feature would be implemented in pdf.js :-) |
+1 please |
+1 |
Any update this... this is needed so that we can change the colors of the reader / pdf for dark mode. Where are these colors even set btw? If someone could point me to the right directly I might be able to hack it to at least build an experimental white on black version instead of a black on white version. We can't just invert the colors because color images will break. filter: invert(85%) Does make regular documents go dark but the images are then broken as their color scheme is now invalid. I think one strategy might be to make the document greyscale but then you lose the colors which isn't fun. |
Wether to leave images alone is debatable. For example, the standalone evince pdf reader inverts colors of images as well. For pictures it leads to strange colors, but graphics and charts usually remain readable and it prevents issues with images having a transparent background or images with a white background that extends under the text. |
This is indeed a problem, but I would already appreciate having just text inverted. |
I just suggest the grayscale is acceptable. Many pdf viewers (e.g. pdf expert) provide many background colors mode. In these model, the document is converted into grayscale and then render the user-defined colors. I think this could make things simpler? |
A toggle button for |
I look forward to this feature being implemented since currently it's a little unintuitive to read PDF in dark mode. On Firefox, I use a JavaScript bookmarklet mentioned here (although I use this version) as a temporary solution. But it would be nicer if there were a better way to use dark theme with pdf.js, such as built-in force-dark-theme feature like the one that comes with Samsung's internet browser (or at least if extensions on Firefox could be allowed to work because AFAIK extensions like Dark Reader don't work on PDFs in Firefox). |
IMO, it would be great to have a button (next to those at the top right) to toggle |
The way this has to work internally, I think, is to have it set at a lower level with the canvas fill options. I looked into and I think it's generally possible but one issue are the colors in figures/charts. They might not look good on a dark background so we might have to get that working too. One plan B could be to have a white background for charts/figures if possible. |
Following the "bookmarklet approach" by @coughingmouse, I created a bookmark on my toolbar with the following variation in the code: javascript:(function(){viewer.style%20=%20'filter:%20grayscale(0)%20invert(0.25)%20sepia(0.8)%20contrast(100%)';})() i.e. grayscale is at 0 (0%), invert at 0.25 (25%), sepia at 0.8 (i.e. 80%) and contrast at 100%. This does not transform the page to a bitonal document - it leaves an "idea of color" in it that I find pleasing to the eye. And sepia is not at its full potential (in combination with the chosen invert percentage), bringing the white background of a PDF page to #F4DEB6 (or so tells me the color picker of gcolor2...) - which is quite close to my favorite "Navajo White" (#FFDEAD). Playing with a custom chrome/userContent.css and a plethora of settings taken from the original viewer.css of pdf.js did NOT bring ANY difference. Changing the viewer.css file inside the .xpi file (it is just a ZIP archive) directly and setting background-color: #FFDEAD; for .page did show a "navajo white" background each time the page/thumbnails were loaded - only to be overwritten by the white background of the PDF page/thumbnail itself! So forget this route, you don't need it. The bookmarklet will do its job for the moment - and for the next 10 years I guess... |
What's the "viewer" in |
Option to pass in a parameter like ?displayMode=dark would also be great. |
Let me do an improvement to the bookmarklet solution: with code mentioned in darkreader/darkreader#374: while the pdf originally looks like this: So as you could notice, |
This is an important accessibility issue, and people have been seeking a fix for literally a decade. How can we encourage Mozilla to make this a priority? |
I love pdf.js and I'd really want inverted colors at low light environments. #8253 |
For anyone interested here is a custom solution I made. It lets you render PDFs not just in dark mode but any color scheme. Similar to what @juarezr and @heitorPB suggested. E.g. Solarized light and dark:
Edit: try the updated demo here. |
That is awesome, @shivaprsd! I'd love to see that work merged into pdf.js, do you think it is possible? |
@heitorPB Highly unlikely; see #13676 (comment) 🙂 I am attempting a Firefox add-on, will post the outcome. |
That's so sad... your solution is really neat and much better than using an external PDF viewer that can invert colors. Looking forward for your addon! |
Here it is: https://github.com/shivaprsd/doqment. It is my first ever extension, so might be a bit naive ATM. Consider as WIP. 🙂 |
A workaround based on the tampermonkey. This is very useful if you are reading a pdf via a browser and just want to change the background color. https://greasyfork.org/en/scripts/437073-pdf-background-color-controller |
A patch is in review: |
So, why is this bug closed? |
@Juraj-Masiar Because the PDF.js team has already implemented it. You just have to enable High-Contrast Mode in your OS/Firefox and choose the FG/BG colours, and it will apply to the PDF viewer and all web pages as well. Edit: it is behind HCM because the team deemed this is likely an accessibility feature. |
The bookmarklet in #2071 (comment) by @LeoJhonSong works nicely in the viewer window, but the thumbnails remain unaffected (white). What needs to be added so that it applies to thumbnails too as in @shivaprsd excellent doqment extension when Filter is chosen? Thx |
@qwer1304 You can add
|
@shivaprsd Thank you. It worked. |
From Options->Content->Colors, I can change the colors for text and background, but these settings are simply ignored. Black-on-white text can strain the eyes, so I think this feature is very important for the sake of health.
Standalone PDF readers, e.g. Adobe Reader, do support changing the colors for customizing an eye-friendly contrast.
The text was updated successfully, but these errors were encountered: