Nutrient 2024.2 migration guide
This guide outlines the changes to Nutrient Android SDK 2024.2.
Breaking API changes
PSPDFKitInitializationProvider was changed to InitializationProvider and moved to a different package, and com.pspdfkit is now com.pspdfkit.initialization.
Additionally, the Jetpack Compose package has been changed. Refer to the Compose Package Structure section for more information.
Deprecations and new APIs
Our old initialize methods in the top-level PSPDFKit class have been deprecated in favor of a single initialize method that takes Context and InitializationOptions.
The following changes have been made:
- All the previous initializemethods have been replaced withinitialize(context: Context, options: InitializationOptions? = null).
- clearCachesreplaced- PSPDFKit.clearCaches(context: Context, clearDiskCache: Boolean)with- PSPDFKit.clearCaches().
- AnnotationEditingController- getCurrentlySelectedAnnotation()is marked as deprecated. It still works, but it only returns the first selected annotation.
- The new method getCurrentlySelectedAnnotations()should be used instead.
- The new method getCurrentSingleSelectedAnnotation()returns the selected annotation only if a single annotation is currently selected.
- The new method hasCurrentlySelectedAnnotations()tells you if anything is selected at all.
 
- The new AnnotationTool.ANNOTATION_MULTI_SELECTIONcan be found in the annotation toolbar and starts annotation multi-selection mode.
- The new method PdfFragment.enterAnnotationEditingMode(@NonNull final List<Annotation> annotations)takes multiple annotations. The old method, which only takes a single annotation as a parameter, is still available.
- OnAnnotationSelectedListenerhas a new method,- onAnnotationSelectionFinished, which is called after all selections have been processed individually and notified via- onAnnotationSelected(opens in a new tab).
Compose package structure
We updated our package structure for multiple files related to Jetpack Compose support.
The files that were accessible before on the com.pspdfkit.jetpack.compose package will be now accessible on new paths, such as com.pspdfkit.jetpack.compose.components.
This is done to better organize the files and make it easier to find the required files.
The files are now organized in the following structure:
- Components— This contains all the independent- Composecomponents that can be used to build a custom UI for Nutrient.
- Interactors— This contains all the files that can be used to interact with the- DocumentView.
- Views— This contains the composable views that can be used to display PDFs.
- Utilities— This contains classes that are used to provide extra functionality.
The new structure looks as follows:
└── 📁compose    └── 📁components        └── MainToolbar.kt    └── 📁interactors        └── DefaultListeners.kt        └── DocumentConnection.kt        └── DocumentListener.kt        └── DocumentManager.kt        └── DocumentState.kt    └── 📁utilities        └── ExperimentalPSPDFKitApi.kt        └── NonFragmentActivityException.kt    └── 📁views        └── DocumentView.kt        └── ImageDocumentView.kt 
  
  
  
 