PSPDFKit 2024.2 Migration Guide
This guide outlines the changes to PSPDFKit for Android 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
initialize
methods have been replaced withinitialize(context: Context, options: InitializationOptions? = null)
. -
clearCaches
replacedPSPDFKit.clearCaches(context: Context, clearDiskCache: Boolean)
withPSPDFKit.clearCaches()
. -
-
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_SELECTION
can 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. -
OnAnnotationSelectedListener
has a new method,onAnnotationSelectionFinished
, which is called after all selections have been processed individually and notified viaonAnnotationSelected
.
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 independentCompose
components that can be used to build a custom UI for PSPDFKit. -
Interactors
— This contains all the files that can be used to interact with theDocumentView
. -
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