Configuring PDF View Properties

The configuration argument in the present() method enables you to customize various properties of the PDF view. Here’s an example showcasing how you can set your PDF view’s configuration:

// First copy the document from assets to the temporary directory.
await Pspdfkit.present(document.path, {
    scrollDirection: 'vertical',
    pageTransition: 'scrollContinuous',
    spreadFitting: 'fit',
    immersiveMode: false,
    userInterfaceViewMode: 'automaticBorderPages',
    androidShowSearchAction: true,
    inlineSearch: false,
    showThumbnailBar: 'floating',
    androidShowThumbnailGridAction: true,
    androidShowOutlineAction: true,
    androidShowAnnotationListAction: true,
    showPageLabels: true,
    documentLabelEnabled: false,
    invertColors: false,
    androidGrayScale: false,
    startPage: 2,
    enableAnnotationEditing: true,
    enableTextSelection: false,
    androidShowBookmarksAction: false,
    androidEnableDocumentEditor: false,
    androidShowShareAction: true,
    androidShowPrintAction: false,
    androidShowDocumentInfoView: true,
    appearanceMode: 'default',
    androidDefaultThemeResource: 'PSPDFKit.Theme.Example',
    iOSRightBarButtonItems: [
      'thumbnailsButtonItem',
      'activityButtonItem',
      'searchButtonItem',
      'annotationButtonItem'
    ],
    iOSLeftBarButtonItems: ['settingsButtonItem'],
    iOSAllowToolbarTitleChange: false,
    toolbarTitle: 'Custom Title',
    settingsMenuItems: [
      'pageTransition',
      'scrollDirection',
      'androidTheme',
      'iOSAppearance',
      'androidPageLayout',
      'iOSPageMode',
      'iOSSpreadFitting',
      'androidScreenAwake',
      'iOSBrightness'],
    showActionNavigationButtons: false,
    pageMode: 'double',
    firstPageAlwaysSingle: true
});

πŸ’‘ Tip: You can find the available configuration options on Android in ConfigurationAdapter.java and on iOS in PspdfkitPlugin.m and PspdfkitFlutterConverter.m.

Configuration Options

Here’s the complete list of configuration options supported by each platform. Note that some options are only supported on a single platform β€” that’s because of differences in the behavior of both of these platforms. Options that work on only one platform are prefixed with the appropriate platform name: android or iOS. The options, grouped by category, are shown below.

Document Interaction Options

Configuration Option Data Type Possible Values iOS Android Description
scrollDirection String horizontal, vertical βœ… βœ… Configures the direction of page scrolling in the document view.
pageTransition String scrollPerSpread, scrollContinuous, curl βœ… βœ… Configures the page scrolling mode. Note that curl mode is only available for iOS and will be ignored on Android.
enableTextSelection Boolean true / false βœ… βœ… Allow / disallow text selection.

Document Presentation Options

Configuration Option Data Type Possible Values iOS Android Description
pageMode String single, double, automatic βœ… βœ… Configure the page mode.
spreadFitting String fit, fill, adaptive βœ… βœ… Controls the page fitting mode. adaptive mode only works on iOS and has no effect on Android.
showPageLabels Boolean true / false βœ… βœ… Displays the current page number.
startPage Integer - βœ… βœ… Configures the starting page number.
documentLabelEnabled Bool true / false βœ… βœ… Shows an overlay displaying the document name.
firstPageAlwaysSingle Boolean true / false βœ… βœ… Option to show the first page separately.
invertColors Boolean true / false βœ… βœ… Inverts the document color if true.
password String - βœ… βœ… The password needed to unlock the document.
androidGrayScale Boolean true / false ❌ βœ… Converts the document colors to grayscale.

User Interface Options

Configuration Option Data Type Possible Values iOS Android Description
inlineSearch Boolean true / false βœ… βœ… Sets the type of search bar to be inline or modular.
toolbarTitle String - βœ… βœ… Sets the title of the toolbar. Note: For iOS, you need to set documentLabelEnabled, iOSUseParentNavigationBar, and iOSAllowToolbarTitleChange to false in your configuration before setting the custom title.
showActionNavigationButtons Boolean true / false βœ… βœ… Show action navigation buttons.
userInterfaceViewMode String automatic, automaticBorderPages, automaticNoFirstLastPage, always, alwaysVisible, alwaysHidden, never βœ… βœ… Configures the user interface visibility.
immersiveMode Boolean true / false βœ… βœ… Hides the user interface if set to true.
appearanceMode String default, night, sepia βœ… βœ… Sets the appearance mode for the document.
settingsMenuItems [Array of String] pageTransition, scrollDirection, androidTheme, iOSAppearance, androidPageLayout, iOSPageMode, iOSSpreadFitting, androidScreenAwake, iOSBrightness βœ… βœ… Options that will be presented in the settings menu. The options prefixed with iOS or Android only work on the respective platform. Options without any prefix work on both platforms.
androidShowSearchAction Boolean true / false ❌ βœ… Enables / disables document search functionality. For iOS, add searchButtonItem to iOSLeftBarButtonItems or iOSRightBarButtonItems to achieve the same functionality.
androidShowOutlineAction Boolean true / false ❌ βœ… Enables / disables outline menu in the activity. For iOS, add outlineButtonItem to iOSLeftBarButtonItems or iOSRightBarButtonItems to achieve the same functionality.
androidShowBookmarksAction Boolean true / false ❌ βœ… Enables / disables the bookmark list. For iOS, add bookmarkButtonItem to iOSLeftBarButtonItems or iOSRightBarButtonItems to achieve the same functionality.
androidShowShareAction Boolean true / false ❌ βœ… Enables the display of share features. For iOS, add activityButtonItem to iOSLeftBarButtonItems or iOSRightBarButtonItems to achieve the same functionality.
androidShowPrintAction Boolean true / false ❌ βœ… Enables the printing option in the menu, if applicable, for the document and the device. For iOS, add printButtonItem to iOSLeftBarButtonItems or iOSRightBarButtonItems to achieve the same functionality.
androidShowDocumentInfoView Boolean true / false ❌ βœ… Enables the display of document information. For iOS, add outlineButtonItem to iOSLeftBarButtonItems or iOSRightBarButtonItems to achieve the same functionality.
androidEnableDocumentEditor Boolean true / false ❌ βœ… Enables / disables the document editor button. For iOS, add documentEditorButtonItem to iOSLeftBarButtonItems or iOSRightBarButtonItems to achieve the same functionality.
androidDarkThemeResource String - ❌ βœ… The resource string for the dark theme.
androidDefaultThemeResource String - ❌ βœ… The resource string for the default theme.
iOSLeftBarButtonItems [Array of String] closeButtonItem, outlineButtonItem, searchButtonItem, thumbnailsButtonItem, documentEditorButtonItem, printButtonItem, openInButtonItem, emailButtonItem, messageButtonItem, annotationButtonItem, bookmarkButtonItem, brightnessButtonItem, activityButtonItem, settingsButtonItem, readerViewButtonItem βœ… ❌ Set the left bar button items. For Android, set individual options such as androidShowOutlineAction, androidShowSearchAction, etc. to achieve the same functionality.
iOSRightBarButtonItems [Array of String] closeButtonItem, outlineButtonItem, searchButtonItem, thumbnailsButtonItem, documentEditorButtonItem, printButtonItem, openInButtonItem, emailButtonItem, messageButtonItem, annotationButtonItem, bookmarkButtonItem, brightnessButtonItem, activityButtonItem, settingsButtonItem, readerViewButtonItem βœ… ❌ Set the right bar button items. For Android, set individual options such as androidShowOutlineAction, androidShowSearchAction, etc. to achieve the same functionality.
iOSAllowToolbarTitleChange Boolean true / false βœ… ❌ Allow PSPDFKit to change the title of this view controller.

Thumbnail Options

Configuration Option Data Type Possible Values iOS Android Description
showThumbnailBar String none, default, floating, pinned, scrubberBar, scrollable βœ… βœ… Thumbnail bar mode controls the display of page thumbnails viewing a document.
androidShowThumbnailGridAction Boolean true / false ❌ βœ… Displays an action bar icon to show a grid of thumbnail pages. For iOS, add thumbnailsButtonItem to iOSLeftBarButtonItems or iOSRightBarButtonItems to achieve the same functionality.

Annotation, Forms, and Bookmark Options

Configuration Option Data Type Possible Values iOS Android Description
enableAnnotationEditing Boolean true / false βœ… βœ… Configuration to enable / disable editing all annotations.
androidShowAnnotationListAction Boolean true / false ❌ βœ… Enables the list of annotations. For iOS, add outlineButtonItem to iOSLeftBarButtonItems or iOSRightBarButtonItems to achieve the same functionality.