How do I invert the colors of a PDF when displaying it?

Q:

I want to display PDFs in “night mode”, where colors are all inverted — black is white, white is black, etc. Is there an easy way to do so with PDFNet?

A:

There are several ways you could invert all colors of a page.

Probably the easiest is just to add a white rectangle with a blend mode of Difference, which will cause all colours to display their inverse. (I’ve attached an example PDF with just such an annotation.) The PDFNet Android SDK makes it easy to add new custom annotations, so it would be possible to add a button to invert the colours of the page by adding a page-sized rectangle.

That said, there are many other methods for inverting colours if this one is problematic, such as directly editing the colours of each PDF element (http://www.pdftron.com/pdfnet/samplecode.html#ElementEdit).

In PDFNet versions 6.3 or above, you can also use the PDFViewCtrl.SetColorPostProcessMode method to invert colors (for night mode).

For example, this method on iOS is documented at https://www.pdftron.com/pdfnet/mobile/docs/iOS/src/interface_p_t_p_d_f_view_ctrl.html#a5f0d0930f2e54360d1ef19137bec4122.