PSPDFKit 6 Migration Guide | Android

PSPDFKit 6 for Android is a major release and includes many new features and a few breaking changes. This article provides a set of guidelines for migrating from PSPDFKit 5.5 for Android to PSPDFKit 6.0 for Android.

Updated Dependencies

With PSPDFKit 6, we updated various dependencies of PSPDFKit:

  • Build System Dependencies

    • The Android Gradle plugin used to build PSPDFKit was updated to version 3.5.0. In addition, all sample applications now use Android Gradle plugin 3.5.0 as well.

    • Kotlin was updated to version 1.3.50.

Merge of PSPDFKit and Instant Libraries

Starting with PSPDFKit 6.0, we no longer provide separate libraries for PSPDFKit and Instant. Instant client code is now part of the PSPDFKit library.

If you are currently using Instant and want to update to 6.0, you need to remove its dependency from your project’s dependencies block and add the OkHttp dependency, like so:

dependencies {
    implementation 'com.pspdfkit:pspdfkit:6.0'
-   implementation 'com.pspdfkit:pspdfkit-instant:5.5.0'
+   implementation 'com.squareup.okhttp3:okhttp:3.11.0'
}

Notable Changes and Deprecations

Dropped Deprecated Fields and Methods

Here’s a list of other fields and methods we dropped:

  • AnnotationProvider#getAllAnnotationsOfType() no longer returns Observable<Annotation> but now returns List<Annotation>. You can use AnnotationProvider#getAllAnnotationsOfTypeAsync() instead.

  • PdfFragment#getAnnotationDefaults(). Use PdfFragment#getAnnotationConfiguration() instead.

  • PdfFragment#setAnnotationDefaultsProvider(). Use AnnotationConfigurationRegistry#put() instead.

  • PSPDFKit#setLoggingEnabled(). To disable logging, remove all loggers via PdfLog#removeAllLoggers(). Alternatively, implement a custom logging policy by setting multiple custom Loggers via PdfLog#setLoggers(Logger...).

  • AnnotationDefaultsManager. Replaced by AnnotationConfigurationRegistry.

  • AnnotationDefaultsProvider. Replaced by AnnotationConfiguration.

  • com.pspdfkit.annotations.defaults.AnnotationProperty. Use com.pspdfkit.annotations.configuration.AnnotationProperty instead.

  • AnnotationAggregationStrategyDefaultsProvider. Use AnnotationAggregationStrategyConfiguration instead.

  • AnnotationDefaultsAlphaProvider. Use AnnotationAlphaConfiguration instead.

  • AnnotationDefaultsBorderStyleProvider. Use AnnotationBorderStyleConfiguration instead.

  • AnnotationDefaultsColorProvider. Use AnnotationColorConfiguration instead.

  • AnnotationDefaultsFillColorProvider. Use AnnotationFillColorConfiguration instead.

  • AnnotationDefaultsFontProvider. Use AnnotationFontConfiguration instead.

  • AnnotationDefaultsLineEndTypeProvider. Use AnnotationLineEndsConfiguration instead.

  • AnnotationDefaultsNoteIconProvider. Use AnnotationNoteIconConfiguration instead.

  • AnnotationDefaultsOutlineColorProvider. Use AnnotationOutlineColorConfiguration instead.

  • AnnotationDefaultsOverlayTextProvider. Use AnnotationOverlayTextConfiguration instead.

  • AnnotationDefaultsPreviewProvider. Use AnnotationDefaultsProvider instead.

  • AnnotationDefaultsRepeatOverlayTextProvider. Use AnnotationOverlayTextConfiguration instead.

  • AnnotationDefaultsTextSizeProvider. Use AnnotationTextSizeConfiguration instead.

  • AnnotationDefaultsThicknessProvider. Use AnnotationThicknessConfiguration instead.

  • AnnotationDefaultsStampProvider. Use StampAnnotationConfiguration.Builder instead.

  • EraserDefaultsProvider. Use EraserToolConfiguration.Builder instead.

  • FileAnnotationDefaultsProvider. Use FileAnnotationConfiguration.Builder instead.

  • FreeTextAnnotationDefaultsProvider. Use FreeTextAnnotationConfiguration.Builder instead.

  • InkAnnotationDefaultsProvider. Use InkAnnotationConfiguration.Builder instead.

  • LineAnnotationDefaultsProvider. Use LineAnnotationConfiguration.Builder instead.

  • MarkupAnnotationDefaultsProvider. Use MarkupAnnotationConfiguration.Builder instead.

  • NoteAnnotationDefaultsProvider. Use NoteAnnotationConfiguration.Builder instead.

  • RedactionAnnotationDefaultsProvider. Use RedactionAnnotationConfiguration.Builder instead.

  • ShapeAnnotationDefaultsProvider. Use ShapeAnnotationConfiguration.Builder instead.

  • StampAnnotationDefaultsProvider. Use StampAnnotationConfiguration.Builder instead.

  • DEFAULT_STAMP_ANNOTATION_PDF_WIDTH, DEFAULT_STAMP_ANNOTATION_PDF_HEIGHT, and DEFAULT_STAMP_ANNOTATION_ASPECT_RATIO have been moved from StampAnnotationDefaultsProvider to StampPickerItem.

  • AnnotationPreferencesManager#getBorderStyle(). Use BorderStylePreset#getBorderStyle() on the border style preset returned via AnnotationPreferencesManager#getBorderStylePreset().

  • AnnotationPreferencesManager#setBorderStyle(). Configure BorderStyle in BorderStylePreset and set it via AnnotationPreferencesManager#setBorderStylePreset().

  • AnnotationPreferencesManager#getBorderDashArray(). Use BorderStylePreset#getDashArray() on the border style preset returned via AnnotationPreferencesManager#getBorderStylePreset().

  • AnnotationPreferencesManager#setBorderDashArray(). Use BorderStylePreset set via AnnotationPreferencesManager#setBorderStylePreset().

  • PdfConfiguration.Builder#textSharingEnabled(). Use PdfConfiguration.Builder#setEnabledShareFeatures() with ShareFeatures#TEXT_SELECTION_SHARING, ShareFeatures.NOTE_ANNOTATION_SHARING, and ShareFeatures.FREE_TEXT_ANNOTATION_SHARING instead.

  • PdfConfiguration.Builder#embeddedFileSharingEnabled(). Use PdfConfiguration.Builder#setEnabledShareFeatures() with ShareFeatures#EMBEDDED_FILE_SHARING instead.

  • PdfConfiguration.Builder#sharingNoteEditorContentEnabled(). Use PdfConfiguration.Builder#setEnabledShareFeatures() with ShareFeatures#NOTE_EDITOR_CONTENT_SHARING instead.

  • PdfConfiguration.Builder#setSignatureSavingEnabled(). Use PdfConfiguration.Builder#signatureSavingStrategy() instead.

  • PdfConfiguration.Builder#setCustomerSignatureFeatureEnabled(). Use PdfConfiguration.Builder#signatureSavingStrategy() instead.

  • PdfConfiguration#isTextSharingEnabled(). Use PdfConfiguration#getEnabledShareFeatures() and check if ShareFeatures#TEXT_SELECTION_SHARING is enabled.

  • PdfConfiguration#isEmbeddedFilesSharingEnabled(). Use PdfConfiguration#getEnabledShareFeatures() and check if ShareFeatures#EMBEDDED_FILE_SHARING is enabled.

  • PdfConfiguration#isSharingNoteEditorContentEnabled(). Use PdfConfiguration#getEnabledShareFeatures() and check if ShareFeatures#NOTE_EDITOR_CONTENT_SHARING is enabled.

  • PdfConfiguration#isSignatureSavingEnabled(). Use PdfConfiguration#getSignatureSavingStrategy() instead.

  • PdfConfiguration#isCustomerSignatureFeatureEnabled(). Use PdfConfiguration#getSignatureSavingStrategy() instead.

  • PdfActivityConfiguration.Builder#sharingNoteEditorContentEnabled(). Use PdfActivityConfiguration.Builder#enabledShareFeatures() with ShareFeatures#NOTE_EDITOR_CONTENT_SHARING instead.

  • PdfActivityConfiguration.Builder#enableShare(). Use PdfActivityConfiguration.Builder#enabledShareFeatures() with ShareFeatures.all() instead.

  • PdfActivityConfiguration.Builder#disableShare(). Use PdfActivityConfiguration.Builder#enabledShareFeatures() with ShareFeatures.none() instead.

  • PdfActivityConfiguration.Builder#setSignatureSavingEnabled(). Use PdfActivityConfiguration.Builder#signatureSavingStrategy() instead.

  • PdfActivityConfiguration.Builder#setCustomerSignatureFeatureEnabled(). Use PdfActivityConfiguration.Builder#signatureSavingStrategy() instead.

  • PdfActivityConfiguration#isShareEnabled(). Use PdfActivityConfiguration#getEnabledShareFeatures() instead.

  • ThumbnailBarMode#THUMBNAIL_BAR_MODE_DEFAULT. Use ThumbnailBarMode#THUMBNAIL_BAR_MODE_FLOATING instead.

  • PdfProcessorTask#addPdfToPage(). Use PdfProcessorTask#mergePage() instead.

  • SearchOptions.Builder(Context). Use no parameter constructor instead.

  • TextSearch(Context, PdfDocument, PdfConfiguration). Use TextSearch(PdfDocument, PdfConfiguration) instead.

  • Signer#OnSigningCompleteCallback. Signer#signFormField() is now blocking and no longer requires this callback.

  • Signer#signFormField(SignatureFormField, BiometricSignatureData, OutputStream, OnSigningCompleteCallback). Use Signer#signFormField(SignerOptions) instead.

  • Signer#signFormField(SignerOptions, OnSigningCompleteCallback). Use Signer#signFormField(SignerOptions) instead.

  • Signer#signFormFieldAsync(SignatureFormField, BiometricSignatureData, OutputStream). Use Signer#signFormFieldAsync(SignerOptions) instead.

  • SignaturePickerFragment#setSignaturePickerOrientation(). Pass in the desired SignatureOptions to SignaturePickerFragment#show() instead.

  • SignaturePickerFragment#showSignaturePicker(). Use SignaturePickerFragment#show() instead.

  • AnnotationCreationController#getBorderStyle(). Use border style via BorderStylePreset#getBorderStyle() returned by AnnotationCreationController#getBorderStylePreset().