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. |