Changing text selection / highlight colors
See original GitHub issueHi, I’m using a slightly modified version of NightPDF to read PDFs. I read with complete inversion, so white text is displayed on a black background. However, I can hardly see the text highlight colors at all, especially when I use the find feature. I also have a color-deficiency, and this may be part of the problem.
Here are the default colors:
Normal Selection:
Find:
I can hardly see these, and would like to make it a strong yellow or blue (FFFF00 or 0000FF).
NightPDF applies a filter that changes colors on the page. This can be seen in this js file at line 444. I just set inversion to 100% and leave all other settings at 0/default.
In order to try changing the highlight or find color, I tried to add this to the css:
const highlightStyle = "\n.textLayer .highlight {\n" +
" background-color: rgba(0, 0, 0, 1);\n" +
" }\n" +
".textLayer .highlight.selected {\n" +
" background-color: rgba(0, 0, 0, 1);\n" +
"}" +
".textLayer ::selection {\n" +
" background: rgba(0, 0, 0, 1);\n" +
"}"
This is then added to the iFrames css. I used text_layer_builder.css to try to find find the right css. The reason I made the highlights all black was because I was trying to get it to show up as white (just for testing purposes) on the black background. Then, iI would try to ge it to the right color.
So my expectation with the above css was to see a white highlight on the black background. However, the highlight is grey:
Normal highlight:
Find:
In addition, I tried turning off the inversion filter in NightPDF (and thus expected a black highlight), but it was still grey:
Normal highlight
Find highlight
So, my one question here is really how can I have the direct control over the text selection/highlight/find color
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top GitHub Comments
Please note that that’s a different project, which is not connected to the PDF.js project, and as such we unfortunately cannot really provide (much) help/support for that here.
Perhaps this is what you’re looking for? https://github.com/mozilla/pdf.js/blob/a2652bafd91db17ad30a70bb1be703666efdea49/web/text_layer_builder.css#L23
(Please note that the general problem of inverting document colours is tracked in issue #2071.)
For future reference: When opening an issue, please provide all of the information requested in https://github.com/mozilla/pdf.js/blob/master/.github/ISSUE_TEMPLATE.md such that the issue becomes easily actionable/valid.
Understood! Thank you for all the information.