View mode

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

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):

1private PDFViewCtrl mPdfViewCtrl;
2// ...
3public void showViewModeDialog(FragmentManager fragmentManager) {
4 ViewModePickerDialogFragment dialog = ViewModePickerDialogFragment.newInstance(mPdfViewCtrl.getPagePresentationMode(), false, false, 0);
5 // Set a custom style for this dialog
6 dialog.setStyle(DialogFragment.STYLE_NORMAL, com.pdftron.pdf.tools.R.style.PDFTronAppTheme);
7 // Show the dialog
8 dialog.show(fragmentManager, "view_mode_picker");
9}

Set view mode dialog listener

In order to let users pick PDF page presentation mode, color mode, etc. you need to set a ViewModePickerDialogFragmentListener by calling setViewModePickerDialogFragmentListener. Implement each method in the listener to change page presentation mode, color mode, reflow, etc.

1dialog.setViewModePickerDialogFragmentListener(new ViewModePickerDialogFragment.ViewModePickerDialogFragmentListener() {
2 /**
3 * Called when a view mode has been selected.
4 *
5 * @param viewMode The selected view mode
6 */
7 @Override
8 public void onViewModeSelected(String viewMode) {
9 // Implement functionality for each view mode selected
10 // ...
11 }
12
13 /**
14 * Called when a color mode has been selected.
15 *
16 * @param colorMode The color mode
17 * @return True if the dialog should be dismissed
18 */
19 @Override
20 public boolean onViewModeColorSelected(int colorMode) {
21 return false;
22 }
23
24 /**
25 * Called when a custom color mode is selected
26 *
27 * @param bgColor The selected background color
28 * @param txtColor The selected text color
29 * @return True if the dialog should be dismissed
30 */
31 @Override
32 public boolean onCustomColorModeSelected(int bgColor, int txtColor) {
33 return false;
34 }
35
36 /**
37 * Called when the dialog has been dismissed.
38 */
39 @Override
40 public void onViewModePickerDialogFragmentDismiss() {
41 // Do something when the dialog is dismissed
42 }
43
44 /**
45 * The implementation should zoom in/out reflow
46 *
47 * @param flagZoomIn True if zoom in; False if zoom out
48 * @return The text size raging from 0 to 100
49 */
50 @Override
51 public int onReflowZoomInOut(boolean flagZoomIn) {
52 return 0;
53 }
54
55 /**
56 * The implementation should check tab conversion and shows the alert if needed.
57 *
58 * @param messageID The message ID
59 * @param allowConverted True if conversion is allowed
60 * @return True if handled
61 */
62 @Override
63 public boolean checkTabConversionAndAlert(int messageID, boolean allowConverted) {
64 return false;
65 }
66});

In onViewModeSelected(String), 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