View mode (Android)

There are a few view modes which can be adjusted to provide an optimal presentation such as layout, fit, or reflow. Additionally, you can present a view mode dialog allowing a user to change these settings.

View mode dialog

This tutorial only applies to Xamarin.Android.

ViewModePickerDialogFragment allows users to: pick page layout mode, select page color mode, rotate pages, and crop pages.

Apryse Docs Image

Show view mode dialog

To show a view mode dialog in your activity, create a new instance of ViewModePickerDialogFragment by calling newInstance(PagePresentationMode, boolean, boolean, int):

C#

1public void ShowViewModeDialog()
2{
3 var viewModeDialog = pdftron.PDF.Dialog.ViewModePickerDialogFragment.NewInstance(mPdfViewCtrl.PagePresentationMode,
4 false, mReflowControl.Visibility == ViewStates.Visible, 0);
5 viewModeDialog.SetStyle((int)DialogFragmentStyle.Normal, Resource.Style.PDFTronAppTheme);
6 viewModeDialog.Show(this.SupportFragmentManager, "view_mode_picker");
7}

Set view mode dialog listener

In order to let users pick PDF page presentation mode, color mode, etc. you need to implement the corresponding events in the ViewModePickerDialogFragment instance.

C#

1viewModeDialog.CustomColorModeSelected += (sender, e) =>
2{
3 // save the selection so we can retrieve it next time
4 PdfViewCtrlSettingsManager.SetCustomColorModeBGColor(this, e.BgColor);
5 PdfViewCtrlSettingsManager.SetCustomColorModeTextColor(this, e.TxtColor);
6 PdfViewCtrlSettingsManager.SetColorMode(this, PdfViewCtrlSettingsManager.KeyPrefColorModeCustom);
7 // Do something with e.BgColor and e.TxtColor
8};
9
10viewModeDialog.ViewModeColorSelected += (sender, e) =>
11{
12 // save the selection so we can retrieve it next time
13 PdfViewCtrlSettingsManager.SetColorMode(this, e.ColorMode);
14 // Do something with e.ColorMode
15};
16
17viewModeDialog.ViewModeSelected += (sender, e) =>
18{
19 // Do something with e.ViewMode
20};

In ViewModeSelected, the selected view mode values are defined in PdfViewCtrlSettingsManager and include the following:

View Mode

Description

Value

KEY_PREF_VIEWMODE_CONTINUOUS_VALUE

Single page in continuous mode is selected.

"continuous"

KEY_PREF_VIEWMODE_SINGLEPAGE_VALUE

Single page presentation mode is selected.

"singlepage"

KEY_PREF_VIEWMODE_FACING_VALUE

Facing two pages presentation mode is selected.

"facing"

KEY_PREF_VIEWMODE_FACINGCOVER_VALUE

Facing two pages with odd page number on right side of PDF is selected.

"facingcover"

KEY_PREF_VIEWMODE_FACING_CONT_VALUE

In continuous mode, Facing two pages presentation mode is selected.

"facing_cont"

KEY_PREF_VIEWMODE_FACINGCOVER_CONT_VALUE

In continuous mode, Facing two pages with odd page number on right side of PDF is selected.

"facingcover_cont"

KEY_PREF_VIEWMODE_ROTATION_VALUE

Rotate pdf pages is selected.

"rotation"

KEY_PREF_VIEWMODE_USERCROP_VALUE

User-level crop pages is selected.

"user_crop"

To learn about setting page presentation mode, see PDFViewCtrl page presentation mode .

To learn about setting page color mode, see PDFViewCtrl color modes .

To learn about reflow, see reflow .

To learn about cropping pages, see crop page dialog .

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales