Some test text!
Android / Guides
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.
ViewModePickerDialogFragment
allows users to: pick page layout mode , select page color mode , rotate pages , and crop pages .
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");
}
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 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" |
Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales