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

[FR] Dark Mode Support in Scanned PDFs (Images) #279

Open
LeonelRFF opened this issue Oct 4, 2024 · 6 comments
Open

[FR] Dark Mode Support in Scanned PDFs (Images) #279

LeonelRFF opened this issue Oct 4, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@LeonelRFF
Copy link

Describe your request

Hello, I would like to ask about the possibility of incorporating dark mode for scanned PDFs, that is, those that are only images and are not editable since they do not contain selectable text. I suppose it is different since the color of the images would have to be inverted.
As for the dark mode for the rest of the PDFs that I use, it works well 👌
Regards

@LeonelRFF LeonelRFF added the enhancement New feature or request label Oct 4, 2024
@Lorenz38
Copy link

Describe your request

Hello, I would like to ask about the possibility of incorporating dark mode for scanned PDFs, that is, those that are only images and are not editable since they do not contain selectable text. I suppose it is different since the color of the images would have to be inverted. As for the dark mode for the rest of the PDFs that I use, it works well 👌 Regards

Hello LeonelRFF,
I’m relatively new in this topic and can’t figure out how to turn on the dark mode for PDF files in PDF++.
How did you do that?

And sorry that I could not help you with the scanned PDFs. It would be nice if it worked!

@LeonelRFF
Copy link
Author

Hi, it's on top 👆😊

image

Repository owner deleted a comment Oct 24, 2024
@RyotaUshio
Copy link
Owner

PSA: deleted a potential spam comment. The comment author posted the exact same text in 4 of the issues in this repository at almost the same time, and the text included an unknown link. I also reported the account to GitHub.

@LeonelRFF
Copy link
Author

That's right, I saw it

@carpetdev
Copy link

carpetdev commented Nov 7, 2024

@LeonelRFF Note that the dark mode for the pdf viewer which you've pointed out is actually a feature of vanilla obsidian.

Below is a CSS snippet that hopefully works to invert image-based/image-only pdfs:

.theme-dark .pdf-container:has(.textLayer :first-child.endOfContent) canvas {
    filter: invert(1);
}

I don't know much about pdfs or why obsidian doesn't invert these image-only ones already so this is a bit of a guess but it seems to work for this one: https://nlsblog.org/wp-content/uploads/2020/06/image-based-pdf-sample.pdf

Note that all of the above has nothing to do with this plugin.

However, if you want rectangular pdf embeds from this plugin to be in dark mode then this snippet works:

.theme-dark .pdf-cropped-embed {
    filter: invert(1);
}

Feel free to play around with the CSS rule a bit to get it looking nicer (eg. reduce the invert and change the brightness and contrast too - you can copy what some themes do).

@RyotaUshio there isn't an option in the plugin to invert the rectangular embeds by default is there? I might have just missed it so let me know and I can update this comment if so.

@xell
Copy link

xell commented Nov 11, 2024

In the latest version of Obsidian, I use this css selector to invert the pdf:

.theme-dark .pdf-viewer {
    filter: invert(0.85);
}

And it works for scanned PDFs. However, now I prefer and recommend this smart solution https://github.com/harttraveller/obsidian-pdf-color-inverter. By simply duplicating and renaming the original PDF, we can have both original and inverted versions simultaneously in case that the brutal invert() might have very ugly effects for some contents.

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

No branches or pull requests

5 participants