Night mode and custom color mode

In this document
chevron_rightIn Xamarin.Android
chevron_rightIn Xamarin.iOS

Both Xamarin.iOS and Xamarin.Android have the same flags for color modes:

Color modeConstant value
Day modePDFRasterizer.ColorPostProcessMode.e_postprocess_none
Night modePDFRasterizer.ColorPostProcessMode.e_postprocess_night_mode
Inverted color modePDFRasterizer.ColorPostProcessMode.e_postprocess_invert
Custom color modePDFRasterizer.ColorPostProcessMode.e_postprocess_gradient_map

In Xamarin.Android

Using night mode and custom color mode in Xamarin.Android is identical to using night mode and custom color mode in Android. See tutorial here.

For example, the equivalent of the example provided in the Android guide will be:

To set the color mode to night mode:

mPdfViewCtrl.SetColorPostProcessMode(PDFRasterizer.ColorPostProcessMode.e_postprocess_night_mode);

where mPdfViewCtrl is an instance of PDFViewCtrl.

To set the client area color to black for night mode:

mPdfViewCtrl.SetClientBackgroundColor(0, 0, 0, false);

To set white point to dark gray and black points to red:

var backgroundColor = Android.Graphics.Color.DarkGray;
var textColor = Android.Graphics.Color.Red;
mPdfViewCtrl.SetColorPostProcessColors(backgroundColor, textColor);

To update PDFViewCtrl to redraw the contents:

mPdfViewCtrl.Update(true);

In Xamarin.iOS

Using night mode and custom color mode in Xamarin.iOS is identical to using night mode and custom color mode in iOS. See tutorial here.

For example, the equivalent of the example provided in the iOS guide will be:

To set the color mode to night mode:

mPdfViewCtrl.SetColorPostProcessMode(PDFRasterizer.ColorPostProcessMode.e_postprocess_night_mode);

where mPdfViewCtrl is an instance of PDFViewCtrl.

To set the client area color to black for night mode:

mPdfViewCtrl.SetBackgroundColor(0, 0, 0, false);

To set white point to light brown and black points to dark brown:

var darkBrown = new UIKit.UIColor(0.24f, 0.15f, 0.04f, 1.0f);
var lightBrown = new UIKit.UIColor(0.96f, 0.88f, 0.79f, 1.0f);
mPdfViewCtrl.SetColorPostProcessColors(lightBrown, darkBrown);

To update PDFViewCtrl to redraw the contents:

mPdfViewCtrl.Update(true);