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

Not working in PDF viewing #374

Closed
ghost opened this issue Apr 17, 2018 · 47 comments · Fixed by #2367
Closed

Not working in PDF viewing #374

ghost opened this issue Apr 17, 2018 · 47 comments · Fixed by #2367
Labels

Comments

@ghost
Copy link

ghost commented Apr 17, 2018

According to some review and my experience on Chrome.

@yubo56
Copy link

yubo56 commented Apr 19, 2018

This is currently working for me again, mark as resolved?

@ghost
Copy link
Author

ghost commented Apr 19, 2018

This is working for me only in Filter/Filter+ in Chrome and Vivaldi (on Chromium).
What about Firefox releases - I don't know, but I checked Dev Edition (60.0beta) and there is a completely different PDF viewer, where Dark Reader doesn't work in all modes.

@alexanderby
Copy link
Member

Firefox viewer seems to be invertable. Chrome one is all in one component, it will be tricky to invert page only and it would be impossible to not invert images.

@shaybenmoshe
Copy link

It didn't work for me either a few days ago, but then a couple of days later it started working again (maybe the upgrade to Chrome 66 fixed that somehow).

Anyhow, now I saw the new Dynamic mode, and pdfs aren't inverted by it, nor by static (but they do by both Filter and Filter+).

Thanks for everything!

@yubo56
Copy link

yubo56 commented Apr 27, 2018

^ - yup same experience here

@nimafazeli
Copy link

It does not work on firefox. I am using the last version of ff.
It is odd though because I remember it used to work in the past.

@Raijin56
Copy link

Raijin56 commented Jan 16, 2019

The darkification of PDF files works when using Filter+ (not with Dynamic). My usual solution is saving the config with Filter+ only for the current webpage, but it's annoying doing that with every site that have a PDF.

I suggest to apply Filter+ (if it isn't the default engine) to all PDFs.

EDIT: I forgot to say this is using Chrome 71.0.3578.98 with Dark Reader 4.7.5

@eromoe
Copy link

eromoe commented Mar 19, 2019

@Raijin56 What si Filter+ ???

@sbelharbi
Copy link

@eromoe they are talking about this
Screenshot from 2019-04-06 23-41-54

It seems to work on Chromium, Google Chrome but not on Firefox, nor Waterfox.

@timea-techgirl
Copy link

@rolagg Not possible to make local PDFs dark? My eye strains reading books on computer.

@sbelharbi
Copy link

if by local you mean desktop PDF reader, you can try Evince reader with the option Inverted Colors on. It gives the following results:
dark1

dark2

@timea-techgirl
Copy link

@sbelharbi Hey, thanks for the reply. I mean chrome's built-in PDF reader. I don't have any apps installed. I just drag a PDF to chrome. I wish the extension could make it dark too.

For now, the workaround is to upload the PDF to google drive and read it from there with dark reader extension.

@sbelharbi
Copy link

I see.

  • I just tried reading a local PDF using Google Chromium, and the dark them does not work.
  • Why not use desktop apps to read PDF files? it's more straightforward than using a navigator and go through Google drive. You can write notes/highlight text and so on on desktop apps (Okular for instance which has as well inverted colors, see below). It is tedious to go through a navigator especially if you want to keep track of your readings.
  • FYI, If you are using it only to read books, you can use calibre to organise your library locally. It opens the default reader in the system, though.

dark3

@timea-techgirl
Copy link

I want to have as few apps as possible. Also an old system.

@sbelharbi
Copy link

going through Google drive is a solution, than.
hopefully, the team will add this option to be able to use the them for local files. cc @alexanderby

@MatrixRanger98
Copy link

Agreed with Raijin56. I suggest automatically applying Filter+ to all PDFs. Also, it seems that DarkReader can only accept the site-wise configuration. It would be much more helpful if we could use more customed pattern matching and I don't think there would be any difficulty to implement this feature.

@timea-techgirl
Copy link

For now, the workaround is to upload the PDF to google drive and read it from there with dark reader extension.

This is not working anymore. Pity. :(

@luo-chuan
Copy link

For the same online pdf page in Chrome, the plugin "Midnight Lizard" can invert the page's color, but "Dark Reader" can't.
midnightlizard
darkreaderdynamic

@sbelharbi
Copy link

sbelharbi commented Nov 14, 2019

you may need to change your settings.
google chrome: Version 78.0.3904.97 (Official Build) (64-bit)

Screenshot from 2019-11-14 12-10-31

@eromoe
Copy link

eromoe commented Nov 16, 2019

@luo-chuan you need use Filter+ (过滤+)

@haobangpig
Copy link

I used the Filter+ mode, it works on the online pdf file, but not at the local pdf file.

@zbot473
Copy link

zbot473 commented Dec 17, 2019

Filter+ Causes the Sidebar to become white.

@ele3131
Copy link

ele3131 commented Feb 24, 2020

Black Sidebars would be GREAT! Maybe this turns out to become a 'PDF Mode'

Filter+ isn't perfect for the job yet. (Better than nothing though)

@Franck-Dernoncourt
Copy link

Franck-Dernoncourt commented Feb 29, 2020

How can I configure the Dark Reader Google Chrome extension so that the Filter+ mode is only activated for PDFs? For the other webpages I want to keep the dynamic mode. Also, how can I change the grey background of the PDF preview in Google Chrome to black?

alexanderby pushed a commit that referenced this issue Apr 24, 2020
- Ability to enable or disable for PDFs.
- Fixed #57
- Fixed #114
- Fixed #374
- Fixed #1730
@cool-RR
Copy link

cool-RR commented Apr 26, 2020

Hey, I've had this problem of local PDFs not becoming dark. I switched to Filter+, and it worked on my desktop, but not on my laptop. I ensured they're both the same version (4.9.5). Any idea why it wouldn't work on my laptop? Maybe your new change would fix it? Has it made it to a release yet?

@cool-RR
Copy link

cool-RR commented May 4, 2020

@Gusted @alexanderby Got time to answer my questions above?

@Gusted
Copy link
Contributor

Gusted commented May 4, 2020

We didn't touched PDF make sure you have permission for file:// enabled

@cool-RR
Copy link

cool-RR commented May 4, 2020

Correct, that was the issue. Thank you!

@zbot473
Copy link

zbot473 commented May 4, 2020

Where is the option?
I can't find it on the chrome web store version.

@Gusted
Copy link
Contributor

Gusted commented May 4, 2020

https://darkreader.org/help/en/#faq ->

The extension doesn't work for local files
Open chrome://extensions page, find Dark Reader, click Allow access to file URLs.

@zbot473

@zbot473
Copy link

zbot473 commented May 4, 2020

I can't find the enablePDF option for any pdf files.
Is it part of Filter+ now?

@Gusted
Copy link
Contributor

Gusted commented May 4, 2020

I can't find the enablePDF option for any pdf files.
Is it part of Filter+ now?

It isn't an option yet, it will be an option with darkreader V5

Open a seperate issue for your question

@zbot473
Copy link

zbot473 commented May 4, 2020

Can I just clone the repo and build v5 for myself?

@Gusted
Copy link
Contributor

Gusted commented May 4, 2020

Can I just clone the repo and build v5 for myself?

Buggy and not fast ATM

@zbot473
Copy link

zbot473 commented May 4, 2020

Ok, I'll wait then. Thanks!

@y0rune
Copy link

y0rune commented May 5, 2020

Now it is working in Chrome Browser, but I can not turn it off :(

@Gusted
Copy link
Contributor

Gusted commented May 5, 2020

Open a seperate issue for your question
@y0rune

@ak0005
Copy link

ak0005 commented May 10, 2020

for local pdf in firefox
-> f12>console> viewer.style = 'filter: grayscale(100%) invert(64%) contrast(228%) brightness(80%)'

adjust the numbers according to your preference.

@dn7
Copy link

dn7 commented Jun 8, 2020

for local pdf in firefox
-> f12>console> viewer.style = 'filter: grayscale(100%) invert(64%) contrast(228%) brightness(80%)'

adjust the numbers according to your preference.

You can even run this with one click by creating a new bookmarklet (bookmark) with the following Location (target):
javascript:void(viewer.style = 'filter: grayscale(0%) invert(100%) contrast(100%) brightness(100%)')

Instructions: create a bookmark in Firefox by pressing CTRL+B > right-click the target folder, e.g. "Bookmarks Menu" > "New Bookmark ...".
Note that colors are also inverted, so blue becomes yellow etc. You can make everything grayscale by setting grayscale to 100%. To undo the darkening simply refresh the page (CTRL+R)

@jirikrepl
Copy link
Contributor

it seems to be working fine on file PDF #374 (comment)

but how to set dark reader to not invert toolbar and sides?
Those 3 rectangles are already dark and should not be inverted.

Screen Shot 2021-05-26 at 20 19 13

@Gravifer
Copy link

I find from a reddit thread that you could input

document.querySelector('embed').style.filter = 'invert()'

in the browser console to invert the page without affecting the toolbar and the background.
Does this help to find a solution to @jirikrepl's problem?

@jirikrepl
Copy link
Contributor

jirikrepl commented Jun 1, 2021

@Gravifer I disabled dark mode, opened the console, and pasted your code to it.
It inverts the colors on the pdf page. But inverts all - pdf itself, pdf background and top toolbar (like on my previous screenshot)

I see why it will invert all if I select <ebmed>
Screen Shot 2021-06-01 at 20 52 13

Screen Shot 2021-06-01 at 20 56 53

@Gravifer
Copy link

Gravifer commented Jun 2, 2021

@jirikrepl sorry I didn't clarify the context; I am using Microsoft Edge, and the team modified the viewer plugin. The command actually only inverts the content when the controls are in night mode. Maybe we should hack the plugin already... This is silly.

@TejasO2
Copy link

TejasO2 commented Jul 27, 2021

https://darkreader.org/help/en/#faq ->

The extension doesn't work for local files
Open chrome://extensions page, find Dark Reader, click Allow access to file URLs.

@zbot473

Thanks! This worked smoothly!!

@virenchocha
Copy link

virenchocha commented Jul 29, 2023

As per users, PDF are opening in darkmode if accessed on webpage residing on webserver. Why we can't have a local webserver running and read file from it. I've done exactly that and it works. No extra addins. A few mins of work and you have it.

  • Have darkreader enabled on Chrome
  • Install XAMPP (This will install php, mysql, apache etc.) and it will be rewarding in long run.
  • Open XAMPP and start Apache webserver (in case of error of port change port to 8080 in config file of apche)
  • Make a folder in already existing 'htdocs' subfolder of XAMPP folder and dump .pdf file you want to read there
  • create an index.php file in htdocs and paste following php code.
  • In the below code replace filename with file you want to read.
  • Remeber index.php and .pdf file you want to read must be in same subfolder of 'htdocs' folder of XAMPP
    `<?php
    // Store the file name into variable.
    $file = './filename.pdf';
    $filename = './filename.pdf';

// Header content type
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');

// Read the file
@readfile($file);
?>`

  • Save the file
  • type http://localserver:8080.
  • Voila ! Your PDF file in dark mode will open
  • Feel free to contact or comment.

@JosefLitos
Copy link

JosefLitos commented Nov 6, 2023

Despite the PR being merged, I am failing to get dark PDFs in Firefox:
obrazek
The console command mentioned did work well though, so I assume I must be missing something.
Could anyone direct me where is an option to enable PDFs in firefox?

Edit: I noticed there is a discussion about doqment as a replacement for the default firefox PDF reader with a basic inversion capability.

@luo-chuan
Copy link

If you use Firefox, you can edit userContent.css like this:

@media (prefers-color-scheme: dark){
  .pdfViewer{filter: invert(1) hue-rotate(180deg);}
}

If you use Chrome or Edge, install the extention "PDF Reader", then edit the extention option like this:

html[data-theme*="dark"] .pdfViewer{
  filter: invert(1) hue-rotate(180deg);
}

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

Successfully merging a pull request may close this issue.