Add dark mode support. When dark mode is enabled, colors in the PDF should appear as if the System Preference's "Invert Display Color" mode is turned on. That is, the background of a typical text PDF would appear black and the text would appear white (instead of black text on a white background).
This documentation might be useful.
Last edit: Lane Schwartz 2021-09-17
Possibly also relevant
Last edit: Lane Schwartz 2021-09-17
And https://developer.apple.com/documentation/pdfkit/pdfview/1504612-backgroundcolor
PDF is content. That should not be inverted. Dark mode is about UI, not content. And co,lor inversion has nothing to do with dark mode support.
Christiaan, take a look at how Mail handles Dark Mode. The entire UI background color is black, and the foreground color is white. Is it possible for an email to actively specify its foreground and background colors? Yes. But most emails don't. And those emails that don't appear with white text on black background when Dark Mode is enabled for Mail.
The same could apply to PDFs. I proposed inverting colors because that seems to be a straightforward mechanism to achieve white text on black background.
I read through some of the other closed tickets that were asking for white text on black background. The second two links seem like they might be what you need to get PDFKit to give you that result.
Another option could be adding a preference (or a hidden preference) for to enable Invert Colors. Would you be willing to consider that?
You cannot compare UI. Mail displays text. For text there are dark mode properties defined, and only for specific colors, where the background and foreground have specific dark mode sensitive values. Not PDF content, which defines its own content as it should be displayed. It does not use dynamic colors.And again, color inversion has nothing to do with dark mode.
If you want to define dark mode sensitive PDFs, you should ask Adobe to define =a notion of dark mode sensitive content, and ask Apple to support it. Otherwise, there is nothing to do.
Christiaan,
First of all, thank you for your excellent work on Skim. I really appreciate it.
Secondly, my understanding is that PDFs can specify a background color and can specify a color for text, but most don't. Is that your understanding, too?
Thanks,
Lane
Yes, they can specify background and text colors, and they usually don't provide background colors (in the sense of page background colors). My understanding is that they do provide the text color (usually black). As for the default page background color, that is determined by Apple's PDFView, and cannot be modified. (there was hidden a possibility a long time ago, but Apple disabled that).
Christiaan, thanks. That's helpful.
So in terms of supporting white text on black background, the issue is that PDFKit doesn't allow this. Is that correct?
Yes, that is correct.
OK. That's unfortunate.
If there were a way of setting white text on black background (at least for simple text-heavy PDFs) using PDFKit, is that something that you would be willing to implement (again, assuming it could be done within PDFKit)?
No, as it would not work universally, and we could not know when it would not work (as that is content dependent, not user dependent). Apart from that, it is irrelevant, because there is no way. (I have tried every private pageBackground property in PDFKit, and they do exactly nothing, and there are not even any private text color properties; and then we're talking private, which means unreliable, and prohibited by Apple).
What about modifying the strokeColor and fillColor of the CGContextRef before calling drawPage: toContext?
Edit: updated links to strokeColor and fillColor
Last edit: Lane Schwartz 2021-09-17
Apart from this, what you seem to be referring to is support in UIKit. I see nothing of the kind in AppKit. This is not iOS.
I think the links I sent are for SwiftUI, which can be used for both macOS and iOS. I'm not familiar, though, with the interface between SwiftUI and AppKit.
Skim is not programmed in Swift, and I don't see anything in Objective-C. BTW, m ost of your links are invalid.
Moreover, even as far as it would be possible to bring SwiftUI into an objective-c program, it would never be compatible with older OS versions. And Skim supports up to 10.10. So this is simply impossible.
Right. I'll let you know if I find anything about interfacing the SwiftUI APIs from Objective-C. That might or might not be possible.
Sorry about the broken links. I have now fixed them.
Last edit: Lane Schwartz 2021-09-17
The only thing I see is including some custom SwiftUI views in an ObjC project. But we are talking about an existing view class. Apple simply does not provide the support.
And that is apart from not wanting it.
I found a way to invert the colors in the pdf view. It will be available only through a hidden preference though, because of the reasons detailed above.
How did you invert the colors?
Setting content filters on the displaying views.
I am sorry, but I could not find any content filters. can you please point me to where it is?