PSPDFKit 9.3 Migration Guide
This guide covers updating an iOS or Mac Catalyst project from PSPDFKit 9.2.2 for iOS to PSPDFKit 9.3 for iOS. We encourage you to update as soon as possible, in order to take advantage of future new features and fixes.
PSPDFKit 9.3 for iOS fully supports iOS 11, 12, and 13. iOS 11 support will be removed later during the PSPDFKit 9 lifecycle. Xcode 11.4 or later is required to use this version of the SDK. Learn more in our version support guide.
Document Permissions
A PDF document defines a set of permissions that enable/disable certain actions a user can take with the document. These permissions cover things like printing, annotation modification, and content extraction.
Prior to this release, we could read and write user permissions on a PDF document, but most of them were ignored by the SDK. PSPDFKit 9.3 for iOS adds comprehensive support for all available document permissions so that the relevant UI actions are enabled/disabled based on which permissions are available.
The permissions are defined using the DocumentPermissions
API (PSPDFDocumentPermissions
in Objective-C). Here’s a brief list of the effects each permission has when disabled:
-
.printing
— TheUIActivityTypePrint
activity will be removed from the available sharing activities when using theDocumentSharingConfiguration.Destination.activity
sharing destination, and theDocumentSharingConfiguration.Destination.print
sharing destination will not be available. -
.extract
— The user will not be able to copy selected text or images. -
.assemble
— The user will not be able to enter the Document Editor view mode. -
.annotationsAndForms
— The user will not be able to create new annotations; move, resize, or rotate existing annotations; or add comments to existing annotations. -
.fillForms
— If disabled along with.annotationsAndForms
, the user will not be able to fill in form fields, including signature fields, checkboxes, and radio buttons. -
.modification
— The user will not be able to add or edit bookmarks, redact portions of a document, or edit information like a document’s title and author information.
Make sure to read the document permissions guide to learn more about this, including how to disable this behavior.
Objective-C Changes
If you’re using the PSPDFKit SDK with Swift, jump to the Swift-Only Changes section.
- Changed
Presentation option constants for the
PSPDFPresentationActions
protocol have been deprecated in favor of renamed constants with thePSPDFPresentationOption
prefix. This is for consistency and improved Swift interoperability.
Deprecated API | Replacement API |
---|---|
PSPDFPresentationStyleKey |
PSPDFPresentationOptionPresentationStyle |
PSPDFPresentationHalfModalStyleKey |
PSPDFPresentationOptionHalfModalStyle |
PSPDFPresentationNonAdaptiveKey |
PSPDFPresentationOptionNonAdaptive |
PSPDFPresentationRectBlockKey |
PSPDFPresentationOptionSourceRectProvider |
PSPDFPresentationContentSizeKey |
PSPDFPresentationOptionContentSize |
PSPDFPresentationInNavigationControllerKey |
PSPDFPresentationOptionInNavigationController |
PSPDFPresentationReuseNavigationControllerKey |
PSPDFPresentationOptionReuseNavigationController |
PSPDFPresentationPopoverArrowDirectionsKey |
PSPDFPresentationOptionPopoverArrowDirections |
PSPDFPresentationPopoverPassthroughViewsKey |
PSPDFPresentationOptionPopoverPassthroughViews |
PSPDFPresentationPopoverBackgroundColorKey |
PSPDFPresentationOptionPopoverBackgroundColor |
PSPDFPresentationRectKey |
PSPDFPresentationOptionSourceRect |
PSPDFPresentationCloseButtonKey |
PSPDFPresentationOptionCloseButton |
PSPDFViewControllerSearchHeadlessKey |
PSPDFPresentationOptionSearchHeadless |
- Changed
Similarly, the existing constants used to access the contents of the dictionary objects of
PSPDFGalleryItem
have been deprecated in favor of a new type,PSPDFGalleryItemProperty
.
Deprecated API | Replacement API |
---|---|
PSPDFGalleryItemTypeKey |
PSPDFGalleryItemPropertyType |
PSPDFGalleryItemContentURLKey |
PSPDFGalleryItemPropertyURL |
PSPDFGalleryItemCaptionKey |
PSPDFGalleryItemPropertyCaption |
PSPDFGalleryItemOptionsKey |
PSPDFGalleryItemPropertyOptions |
- Changed
The following cases from the
PSPDFFlexibleToolbarPosition
enum have been deprecated and replaced.
Deprecated API | Replacement API |
---|---|
PSPDFFlexibleToolbarPositionsVertical |
PSPDFFlexibleToolbarPositionVertical |
PSPDFFlexibleToolbarPositionsAll |
PSPDFFlexibleToolbarPositionAll |
- Changed
The existing
PSPDFSettingKey
constants have been deprecated in favor of the new ones, which are more semantically named.
Deprecated API | Replacement API |
---|---|
PSPDFXCallbackURLStringKey |
PSPDFSettingKeyXCallbackURLString |
PSPDFApplicationPolicyKey |
PSPDFSettingKeyApplicationPolicy |
PSPDFFileManagerKey |
PSPDFSettingKeyFileManager |
PSPDFCoordinatedFileManagerKey |
PSPDFSettingKeyCoordinatedFileManager |
PSPDFFileCoordinationEnabledKey |
PSPDFSettingKeyFileCoordinationEnabled |
PSPDFLibraryIndexingPriorityKey |
PSPDFSettingKeyLibraryIndexingPriority |
PSPDFKitDebugModeKey |
PSPDFSettingKeyDebugMode |
PSPDFAdditionalFontDirectories |
PSPDFSettingKeyAdditionalFontDirectories |
PSPDFHonorDocumentPermissionsKey |
PSPDFSettingKeyHonorDocumentPermissions |
- Changed
The existing
PSPDFAnnotationOption
constants have been deprecated in favor of the new ones, which are semantically named for improved Swift interoperability.
Deprecated API | Replacement API |
---|---|
PSPDFAnnotationOptionAnimateViewKey |
PSPDFAnnotationOptionAnimateView |
PSPDFAnnotationOptionSuppressNotificationsKey |
PSPDFAnnotationOptionSuppressNotifications |
- Changed
The
PSPDFRectAlignment
API cases have been renamed to provide better interoperability in Swift.
Previous API | New API |
---|---|
PSPDFRectAlignCenter |
PSPDFRectAlignmentCenter |
PSPDFRectAlignTop |
PSPDFRectAlignmentTop |
PSPDFRectAlignTopLeft |
PSPDFRectAlignmentTopLeft |
PSPDFRectAlignTopRight |
PSPDFRectAlignmentTopRight |
PSPDFRectAlignLeft |
PSPDFRectAlignmentLeft |
PSPDFRectAlignBottom |
PSPDFRectAlignmentBottom |
PSPDFRectAlignBottomLeft |
PSPDFRectAlignmentBottomLeft |
PSPDFRectAlignBottomRight |
PSPDFRectAlignmentBottomRight |
PSPDFRectAlignRight |
PSPDFRectAlignmentRight |
- Changed
The
fields
property ofPSPDFAbstractFormAnnotation
is now typedNSArray<id<PSPDFFormFieldIdentifier>> *
, in order to more clearly document what this property contains. The newly introducedPSPDFFormFieldIdentifier
protocol is a trait added toNSString
andNSNumber
. - Changed
-[PSPDFFreeTextAnnotation convertToIntentType:]
has been deprecated. Use-[PSPDFFreeTextAnnotation convertIntentTypeTo:]
instead. - Changed
-[PSPDFSoundAnnotation initWithRecorder]
has been deprecated. Use-[PSPDFSoundAnnotation initWithRecorderOptions:]
with anil
parameter for options instead.
Swift-Only Changes
If you’re using the PSPDFKit SDK with Objective-C, check out the Objective-C Changes section.
The entire SDK has been carefully tweaked to make the entirety of our API semantic in Swift. We dropped the PSPDF
prefix and tried to group related APIs by nesting them where appropriate and possible. Due to the vastness of the changes, and in order to keep the migration guide concise, we’ve only mentioned the API changes that could break your build and which cannot be fixed using Xcode’s suggestion (the Fix button).
Most of the API changes can be reliably fixed using the Fix All Issues option (Control-Option-Command-F) in Xcode. This fixes all the issues in the currently opened file. Some of the files may require multiple iterations of using Xcode’s fix option, as some the errors will only be caught after the initially shown errors are fixed.
- Changed
The
String
constants used in thePSPDFPresentationActions
protocol have been removed in favor of the new Swiftstruct
type,PresentationOption
. All the places where the old constants are used as arguments will throw an error while compiling since the type of the method arguments has also been changed fromString
to the appropriate new struct type.
Previous API | New API |
---|---|
PSPDFPresentationStyleKey |
.presentationStyle |
PSPDFPresentationHalfModalStyleKey |
.halfModalStyle |
PSPDFPresentationNonAdaptiveKey |
.nonAdaptive |
PSPDFPresentationRectBlockKey |
.sourceRectProvider |
PSPDFPresentationContentSizeKey |
.contentSize |
PSPDFPresentationInNavigationControllerKey |
.inNavigationController |
PSPDFPresentationReuseNavigationControllerKey |
.reuseNavigationController |
PSPDFPresentationPopoverArrowDirectionsKey |
.popoverArrowDirections |
PSPDFPresentationPopoverPassthroughViewsKey |
.popoverPassthroughViews |
PSPDFPresentationPopoverBackgroundColorKey |
.popoverBackgroundColor |
PSPDFPresentationRectKey |
.sourceRect |
PSPDFPresentationCloseButtonKey |
.closeButton |
PSPDFViewControllerSearchHeadlessKey |
.searchHeadless |
- Changed
The constants used for accessing the dictionary values of a
PSPDFGalleryItem
have been replaced with theGalleryItem.Property
struct.
Previous API | New API |
---|---|
PSPDFGalleryItemTypeKey |
.type |
PSPDFGalleryItemContentURLKey |
.contentURL |
PSPDFGalleryItemCaptionKey |
.caption |
PSPDFGalleryItemOptionsKey |
.options |
If any of these types happen to clash with other declarations in Swift, this can be resolved by accessing the type using the module name. For example, use
PSPDFKitUI.GalleryItem.Option.autoPlay
instead ofGalleryItem.Option.autoPlay
.
- Changed
The
PSPDFAnnotationOption
type has been renamed toAnnotationManager.ChangeBehaviorKey
in Swift. Its existing values have been deprecated in favor of semantically named ones.
Deprecated API | New API |
---|---|
.animateViewKey |
.animateView |
.notificationsKey |
.suppressNotifications |
- Changed
The
PSPDFRectAlignment
enumeration has been renamed toRectAlignment
for Swift. Its cases have also been renamed.
Previous API | New API |
---|---|
.alignCenter |
.center |
.alignTop |
.top |
.alignTopLeft |
.topLeft |
.alignTopRight |
.right |
.alignLeft |
.left |
.alignBottom |
.bottom |
.alignBottomLeft |
.bottomLeft |
.alignBottomRight |
.bottomRight |
.alignRight |
.right |
- Changed
PSPDFFlexibleToolbarPosition
has been updated with a new Swift name,FlexibleToolbar.Position
. Some position values have been deprecated and replaced with new ones to ensure better translation to Swift names.
Previous API | New API |
---|---|
.positionNone |
.none |
.positionInTopBar |
.inTopBar |
.positionLeft |
.left |
.positionRight |
.right |
.positionsVertical |
.vertical |
.positionsAll |
.all |
- Changed
PSPDFSettingKey
has been renamed toSDK.Setting
, and the existing constants have been deprecated in favor of new ones, which are more semantically named.
Deprecated API | Replacement API |
---|---|
.PSPDFXCallbackURLStringKey |
.xCallbackURLString |
.applicationPolicyKey |
.applicationPolicy |
.fileManagerKey |
.fileManager |
.coordinatedFileManagerKey |
.coordinatedFileManager |
.fileCoordinationEnabledKey |
.fileCoordinationEnabled |
.libraryIndexingPriorityKey |
.libraryIndexingPriority |
.debugModeKey |
.debugMode |
.additionalFontDirectories |
.additionalFontDirectories |
.honorDocumentPermissionsKey |
.honorDocumentPermissions |
- Changed
PSPDFMetadataName
has been renamed toPDFMetadata.Key
, and the existing constants have been deprecated in favor of new ones, which are more semantically named.
Previous API | New API |
---|---|
.titleKey |
.title |
.authorKey |
.author |
.subjectKey |
.subject |
.keywordsKey |
.keywords |
.creatorKey |
.creator |
.producerKey |
.producer |
.creationDateKey |
.creationDate |
.modDateKey |
.modificationDate |
.trappedKey |
.trapped |
- Changed
PSPDFValueTransformerName
has been renamed toValueTransformerName
, and the existing constants have been replaced. See below for the list.
Previous API | New API |
---|---|
.actionTypeTransformerName |
.actionType |
.annotationTriggerEventTransformerName |
.annotationTriggerEvent |
.borderEffectTransformerName |
.borderEffect |
.borderStyleTransformerName |
.borderStyle |
.freeTextAnnotationIntentTransformerName |
.freeTextAnnotationIntent |
.namedActionTypeTransformerName |
.namedActionType |
.polygonAnnotationIntentTransformerName |
.polygonAnnotationIntent |
.renditionActionTypeTransformerName |
.renditionActionType |
.verticalAlignmentTransformerName |
.verticalAlignment |
- Changed
PSPDFDocumentUnderlyingFileChangedNotificationOptions
has been renamed toDocument.UnderlyingFileChangedNotificationOption
, and the existing constants have been replaced. See below for the list.
Previous API | New API |
---|---|
.urlKey |
.changedFileURL |
.willBeDeletedKey |
.deleteFile |
Annotation API Refinements
- Changed
AnnotationStyleType
has been renamed toAnnotationStyle.Kind
.
Previous API | New API |
---|---|
.titleKey |
.title |
.authorKey |
.author |
.subjectKey |
.subject |
.keywordsKey |
.keywords |
.creatorKey |
.creator |
.producerKey |
.producer |
.creationDateKey |
.creationDate |
- Changed
AnnotationStyleKey
has been renamed toAnnotationStyle.Key
. - Changed
AnnotationString
has been renamed toAnnotation.Tool
. - Changed
AnnotationVariantString
has been renamed toAnnotation.Variant
. - Changed
AnnotationStateVariantID
has been renamed toAnnotation.ToolVariantID
. - Removed
The
PSPDFStringFromAnnotationType()
helper for creatingAnnotation.Tool
fromAnnotation.Kind
has been removed. Use theinit?(kind:)
initializer onAnnotation.Tool
instead. - Removed
The
PSPDFAnnotationTypeFromString()
helper for creatingAnnotation.Kind
fromAnnotation.Tool
has been removed. Use theinit(tool:)
initializer onAnnotation.Kind
instead. - Removed
The
PSPDFAnnotationStateVariantIDMake()
helper for generatingAnnotation.ToolVariantID
has been removed. UseAnnotation.ToolVariantID(tool:, variant:)
instead. - Removed
The
PSPDFAnnotationStateFromStateVariantIdentifier()
helper for extractingAnnotation.Tool
has been removed. Use thetool
property onAnnotation.ToolVariantID
instead. - Removed
The
PSPDFAnnotationVariantFromStateVariantIdentifier()
helper for extractingAnnotation.Variant
has been removed. Use thevariant
property onAnnotation.ToolVariantID
instead. - Changed
The type of the
Annotation.additionalActions
property has been changed to[Annotation.TriggerEvent: Action]
. - Changed
The type of the
Annotation.dashArray
property has been changed to[CGFloat]
. - Changed
The type of the
Annotation.rects
property has been changed to[CGRect]
. - Changed
The type of the
Annotation.points
property has been changed to[CGPoint]
. - Changed
The
AbstractFormAnnotation.fields
property has been renamed tofieldIdentifiers
to more clearly document what this array contains. Its type has been changed from[Any]?
to[FormFieldIdentifier]?
, where the nestedenum FormFieldIdentifier
further documents the semantics. For coding convenience, the enum is bothExpressibleByIntegerLiteral
andExpressibleByStringLiteral
. - Added
A new type,
PDFLine
, which is a type alias for an array ofDrawingPoint
([DrawingPoint]
), has been added. - Added
A new type,
ViewLine
, which is a type alias for an array ofCGPoint
([CGPoint]
), has been added. - Removed
InkAnnotation(lines: [[NSValue]])
has been removed. UseInkAnnotation(lines: [PDFLine])
instead. - Changed
The type of the
InkAnnotation.lines
property has been updated from[[NSValue]]
to[PDFLine]
). - Changed
The type of the
points
parameter in initializers ofAbstractLineAnnotation
(formerlyPSPDFAbstractLineAnnotation
) andPolygonAnnotation
has been updated to an array ofCGPoint
instead of an array ofNSValue
. Updated APIs:AbstractLineAnnotation(points: [CGPoint])
,PolygonAnnotation(points: [CGPoint], intentType: PolygonAnnotation.Intent = .none)
- Removed
FreeTextAnnotation.convert(toIntentType:)
has been deprecated. UseFreeTextAnnotation.convertIntent(to:)
instead. - Changed
The
rects
parameter toTextMarkupAnnotation
’s class method —textOverlayAnnotation(withRects:,boundingBox:,pageIndex:)
— has been changed from[NSValue]
to[CGRect]
. The signature of this method is nowclass func textOverlayAnnotation(withRects rects: [CGRect], boundingBox: CGRect, pageIndex: Int) -> Self?
. - Changed
The
PSPDFAnnotationAuthorState
andPSPDFAnnotationAuthorStateModel
APIs have been consolidated into theAnnotation.State
API, which is an enum with associated values. Below is the list of the possible values for theAnnotation.State
type.
The change above affects the
NoteAnnotation
API. Since the two types have been reorganized into a single type (Annotation.State
),NoteAnnotation
uses a single property (authorState
) to show the author-specific state. This means that the other property,authorStateModel
, has been removed.
Annotation.State |
---|
.unspecified |
.marking(Annotation.State.MarkedModel) |
.reviewing(Annotation.State.ReviewModel) |
- Changed
SoundAnnotation(recorderOptions:)
has been updated to take a parameter of typeSet<SoundAnnotation.RecorderOption>
instead of a dictionary.SoundAnnotation.RecorderOption
is an enum with associated values that can be used to configure a recorder. - Removed
The
SoundAnnotation.initWithRecorder()
API has been removed. UseSoundAnnotation(recorderOptions:)
by passing an empty set as therecorderOptions:
parameter instead.
SoundAnnotation.RecorderOption |
---|
.encoding(SoundAnnotation.Encoding) |
.channels(UInt32) |
.sampleRate(hertz: SoundAnnotation.RecorderOption.SampleRate) |
.bitsPerSample(SoundAnnotation.RecorderOption.Depth) |
Document API Refinements
- Removed
The
save(options: [PSPDFDocumentSaveOption : Any]) throws
API onDocument
(formerlyPSPDFDocument
) has been removed. Use thesave(options: Set<SaveOption>) throws
API instead. - Removed
The
save(options: [PSPDFDocumentSaveOption : Any]?, completionHandler: ((Error?, [PSPDFAnnotation]) -> Void)?)
API ofDocument
has also been removed. Usesave(options: Set<SaveOption> = [], completion: @escaping (Result<[Annotation], Error>) -> Void)
instead.
Note Annotation Icon
- Changed
The icon used for representing the note annotation tool in the annotation toolbar has been replaced. You can read more about how to customize the icon in our customizing the annotation toolbar guide.
Old | New |
---|---|
Flexible Toolbar Position
- Changed
The default value for
FlexibleToolbarPosition
’ssupportedToolbarPositions
property has changed from.all
to.default
. If you were programmatically setting your toolbar’ssupportedToolbarPositions
to.all
, use.default
instead to support the default toolbar positions. For more details on how to customize the toolbar positions, take a look at both our customizing the annotation toolbar guide andToolbarPositionTopExample.swift
from the Catalog app.
Class Overriding
The class overriding mechanism is now more type-safe and better documented. All classes that can be overridden now conform to the Overridable
protocol. Classes that don’t conform to it are no longer accepted by overrideClass(_:with:)
and can no longer participate in the mechanism.
If you were overriding an illicit class, you might now see compile warnings or errors. If you were implementing the Overridable
protocol in your own classes, remove the conformance. It will no longer work with the class overriding mechanism.