How to set colormode dynamically?

Product:

Product Version:

Please give a brief summary of your issue:

We are getting integer value on “public boolean onViewModeColorSelected(int colorMode)” . It return us 3 for Dark, 2 for Light and 1 for None.

Like as we are set view mode using -mPdfViewCtrlTabHostFragment.currentPdfViewCtrlFragment.pdfViewCtrl.pagePresentationMode =PDFViewCtrl.PagePresentationMode.SINGLE_CONT

Same as I tried to set color mode using
mPdfViewCtrlTabHostFragment.currentPdfViewCtrlFragment.pdfViewCtrl.pagePresentationMode = 3
But this made my document black and white or in another view where as 3 is used for dark mode only.

So how can we set light mode or darkmode or none dynamically?

Thanks
Pawan

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Since you are using the Viewer Fragment (PdfViewCtrlTabHostFragment2), you can simply call the following to change your color mode to light or dark mode as follows:

                PdfViewCtrlTabHostFragment2 viewerFragment = ...;
                // Set color mode
                PdfViewCtrlSettingsManager.setColorMode(getContext(), PdfViewCtrlSettingsManager.KEY_PREF_COLOR_MODE_NORMAL);
                // Other colors modes...
                // PdfViewCtrlSettingsManager.setColorMode(getContext(), PdfViewCtrlSettingsManager.KEY_PREF_COLOR_MODE_NIGHT);
                // PdfViewCtrlSettingsManager.setColorMode(getContext(), PdfViewCtrlSettingsManager.KEY_PREF_COLOR_MODE_SEPIA);
                viewerFragment.updateColorMode();

Optionally if you need custom color modes, you can further customize the colors using PDFViewCtrl.setColorPostProcessColors(..). You can learn more about this here: PDFTron