Some test text!

Loading...
Guides

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 .

view mode dialog

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

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

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.

dialog.setViewModePickerDialogFragmentListener(new ViewModePickerDialogFragment.ViewModePickerDialogFragmentListener() {
   /**
    * Called when a view mode has been selected.
    *
    * @param viewMode The selected view mode
    */
    @Override
    public void onViewModeSelected(String viewMode) {
        // Implement functionality for each view mode selected
        // ...
    }

    /**
      * Called when a color mode has been selected.
      *
      * @param colorMode The color mode
      * @return True if the dialog should be dismissed
      */
    @Override
    public boolean onViewModeColorSelected(int colorMode) {
        return false;
    }

    /**
      * Called when a custom color mode is selected
      *
      * @param bgColor  The selected background color
      * @param txtColor The selected text color
      * @return True if the dialog should be dismissed
      */
    @Override
    public boolean onCustomColorModeSelected(int bgColor, int txtColor) {
        return false;
    }

    /**
      * Called when the dialog has been dismissed.
      */
    @Override
    public void onViewModePickerDialogFragmentDismiss() {
        // Do something when the dialog is dismissed
    }

    /**
      * The implementation should zoom in/out reflow
      *
      * @param flagZoomIn True if zoom in; False if zoom out
      * @return The text size raging from 0 to 100
      */
    @Override
    public int onReflowZoomInOut(boolean flagZoomIn) {
        return 0;
    }

    /**
      * The implementation should check tab conversion and shows the alert if needed.
      *
      * @param messageID      The message ID
      * @param allowConverted True if conversion is allowed
      * @return True if handled
      */
    @Override
    public boolean checkTabConversionAndAlert(int messageID, boolean allowConverted) {
        return false;
    }
});

In onViewModeSelected(String), the selected view mode values are defined in PdfViewCtrlSettingsManager and include the following:

View ModeDescriptionValue
KEY_PREF_VIEWMODE_CONTINUOUS_VALUESingle page in continuous mode is selected."continuous"
KEY_PREF_VIEWMODE_SINGLEPAGE_VALUESingle page presentation mode is selected."singlepage"
KEY_PREF_VIEWMODE_FACING_VALUEFacing two pages presentation mode is selected."facing"
KEY_PREF_VIEWMODE_FACINGCOVER_VALUEFacing two pages with odd page number on right side of PDF is selected."facingcover"
KEY_PREF_VIEWMODE_FACING_CONT_VALUEIn continuous mode, Facing two pages presentation mode is selected."facing_cont"
KEY_PREF_VIEWMODE_FACINGCOVER_CONT_VALUEIn continuous mode, Facing two pages with odd page number on right side of PDF is selected."facingcover_cont"
KEY_PREF_VIEWMODE_ROTATION_VALUERotate pdf pages is selected."rotation"
KEY_PREF_VIEWMODE_USERCROP_VALUEUser-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 .

Get the answers you need: Support

UPCOMING WEBINAR: Live tech update and run-through. October 21 @ 11am PDT