Common

  • May be used to override specific subclasses of a controller/view/model.

    See more

    Declaration

    Objective-C

    @protocol PSPDFOverridable <NSObject>

    Swift

    protocol PSPDFOverridable : NSObjectProtocol
  • Document rotation.

    See more

    Declaration

    Objective-C

    enum PSPDFRotation {}

    Swift

    enum Rotation : UInt
  • The PSPDFDocument class represents a set of PDF sources that are displayed as one document.

    The PDF sources are internally represented as data providers (implementations of the PSPDFDataProviding protocol). The typical use case is to initialize the document with a single fileURL, which creates an implicit PSPDFCoordinatedFileDataProvider by default. You can also opt to use NSData or custom implementations of PSPDFDataProviding as sources during initialization.

    This object can be created on any thread. Accessing properties is thread safe but might take some time, as the underlying PDF documents need to be processed to fetch data like pageCount or title. The document builds an internal cache, so subsequent access is faster. For this reason, ensure that document objects are not created/destroyed randomly for maximum efficiency.

    PSPDFDocument supports NSFastEnumeration by enumerating over its documentProviders. The document providers are internal wrappers around the data providers created during initialization.

    Note

    Not all state is archived with NSCoder.

    Note

    Ensure that a PSPDFDocument is only opened by one PSPDFViewController at any time. Also ensure that subclasses do not implement their own equality semantics, and instead use the UID property to check if two documents are equal.

    See more

    Declaration

    Objective-C

    
    @interface PSPDFDocument
        : NSObject <PSPDFDocumentProviderDelegate, PSPDFOverridable, NSCopying,
                    NSSecureCoding, NSFastEnumeration,
                    PSPDFFileCoordinationDelegate>

    Swift

    class PSPDFDocument : NSObject, PSPDFDocumentProviderDelegate, PSPDFOverridable, NSCopying, NSSecureCoding, NSFastEnumeration, PSPDFFileCoordinationDelegate
  • Delegate to receive events regarding PSPDFDocument.

    This delegate offers callbacks for custom actions after save events.

    See more

    Declaration

    Objective-C

    @protocol PSPDFDocumentDelegate <NSObject>

    Swift

    protocol PSPDFDocumentDelegate : NSObjectProtocol
  • A PSPDFDocument consists of one or multiple PSPDFDocumentProvider‘s. Each document provider has exactly one data source (file/data/dataProvider)

    Note

    This class is used within PSPDFDocument and should not be instantiated externally.
    See more

    Declaration

    Objective-C

    
    @interface PSPDFDocumentProvider : NSObject

    Swift

    class PSPDFDocumentProvider : NSObject
  • Delegate for writing annotations.

    See more

    Declaration

    Objective-C

    @protocol PSPDFDocumentProviderDelegate <NSObject>

    Swift

    protocol PSPDFDocumentProviderDelegate : NSObjectProtocol
  • This class describes the security options you want to use when saving a PDF file. Using a security options object overrides the default options of a file.

    A PDF file can have multiple security-related options set. The owner password generally controls the editing of a document and is required as soon as you want to encrypt a document of any kind. The user password prevents users from viewing the PDF. It is optional but if you specify it you also need to specify an owner password.

    You can also specify the key length of the encryption. This controls how large the key is that is used for actually encrypting the document. The key is derived from the passwords you specify. As soon as you specify at least an owner password you also need to decide on a key length to be used. You can also specify PSPDFDocumentSecurityOptionsKeyLengthAutomatic in all cases and let PSPDFKit decide on if and what key length to use.

    To specify what operations are allowed when opening the document with user privileges you can also set PSPDFDocumentPermissions. With user privileges you can always view the file in question and by specifying PSPDFDocumentPermissions you can grant further rights that otherwise would only be available when the user has owner privileges.

    PSPDFKit supports two encryption algorithms: RC4 and AES. RC4 is a proprietary encryption algorithm of RSA Security Inc. It is a symmetric stream cipher, ie. the same algorithm is used for both encryption and decryption, and the algorithm does not change the length of the data. AES support was introduced with PDF 1.6. It is a symmetric block cipher, ie. the same algorithm is used for both encryption and decryption, and the length of the data when encrypted is rounded up to a multiple of the block size, which is fixed in this implementation to always be 16 bytes.

    Note

    In order to use this class, you need a license that enables you to use the Document Editor. If you want to process a file while keeping the options of the original file, simply pass nil for security options.
    See more

    Declaration

    Objective-C

    
    @interface PSPDFDocumentSecurityOptions : NSObject

    Swift

    class PSPDFDocumentSecurityOptions : NSObject
  • PSPDFDocumentFeatures provides the main interface for querying features and registering observers.

    It conforms to PSPDFDocumentFeaturesSource itself, but additionally to the document features source protocol it also guarantees that it implements all methods of this protocol. Therefore it is save to query every feature on an instance of this class without checking its availability for.

    Usually you access this class through PSPDFDocument‘s features property. So if you, for example, want to check if a document can be modified, you can check document.features.canModify.

    See

    -[PSPDFDocument features]

    Threading

    PSPDFDocumentFeatures is thread safe and can be used from any thread. This also means that your custom sources will be called from various threads and queues. Do not rely on being called on a particular thread in your custom sources.

    See more

    Declaration

    Objective-C

    
    @interface PSPDFDocumentFeatures : NSObject <PSPDFDocumentFeaturesSource>

    Swift

    class PSPDFDocumentFeatures : NSObject, PSPDFDocumentFeaturesSource
  • A PSPDFDocument subclass that can be used to display and annotate image files. Can handle JPEG and PNG images.

    Note

    Any transparency on PNG images will be lost after saving.

    Saving changes flattens any annotations into the image and writes it back to the original file. Creating a new document will then reflect the new image with flattened changes. Keep the image document in memory to preserve the ability to edit added annotations.

    PSPDFImageDocument needs the Image Documents feature in your license to work.

    See see https://pspdfkit.com/guides/ios/current/annotations/annotate-images/ for more information.

    See more

    Declaration

    Objective-C

    
    @interface PSPDFImageDocument : PSPDFDocument

    Swift

    class PSPDFImageDocument : PSPDFDocument
  • The PDF Page represents a page of a document. The document is strongly retained.

    Responsibilities:

    • Make working with annotations simpler.
    See more

    Declaration

    Objective-C

    
    @interface PSPDFPage : NSObject

    Swift

    class PSPDFPage : NSObject
  • Wraps file system calls. Internal class cluster. Can be replaced with Enterprise SDK wrappers like Good Technology or MobileIron AppConnect.

    See more

    Declaration

    Objective-C

    @protocol PSPDFFileManager <NSObject>

    Swift

    protocol PSPDFFileManager
  • Coordinates file presenters and notifications. Observed presenters are automatically unregistered in response to UIApplicationDidEnterBackgroundNotification notification.

    See more

    Declaration

    Objective-C

    
    @interface PSPDFFilePresenterCoordinator : NSObject

    Swift

    class PSPDFFilePresenterCoordinator : NSObject
  • Undocumented

    See more

    Declaration

    Objective-C

    NS_ENUM(NSInteger, PSPDFPageBinding) {
        PSPDFPageBindingUnknown,
        PSPDFPageBindingLeftEdge,
        PSPDFPageBindingRightEdge,
    }

    Swift

    enum PSPDFPageBinding : Int
  • Represents PDF page data. Managed within PSPDFDocumentProvider.

    See more

    Declaration

    Objective-C

    
    @interface PSPDFPageInfo : NSObject <NSCopying, NSSecureCoding>

    Swift

    class PSPDFPageInfo : NSObject, NSCopying, NSSecureCoding
  • The PDF render manager coordinates the PDF renderer used.

    See more

    Declaration

    Objective-C

    @protocol PSPDFRenderManager <NSObject>

    Swift

    protocol PSPDFRenderManager : NSObjectProtocol
  • Rendering options. Parameters of how an image should be rendered.

    Declaration

    Objective-C

    typedef NSString *PSPDFRenderOption

    Swift

    struct PSPDFRenderOption : _ObjectiveCBridgeable, Hashable, Equatable, _SwiftNewtypeWrapper, RawRepresentable
  • The render queue is responsible for scheduling and completing tasks. Typically you don’t create your own render queue but instead use the render queue provided by the render manager. Creating your own render queue is possible but due to internal resource constraints will almost never speed up rendering but instead the queues try to access the same resources and then need to wait until the resource becomes available.

    The goal of the render queue is to keep the average time it takes to complete a render task at a minimum. To achieve this the render queue intelligently schedules and bundles tasks. Therefore the order in which scheduled tasks are executed is undefined and depends on many factors.

    See more

    Declaration

    Objective-C

    
    @interface PSPDFRenderQueue : NSObject

    Swift

    class PSPDFRenderQueue : NSObject
  • A render request specifies the exact parameters of how an image should be rendered. You use it in order to configure a PSPDFRenderTask which can then be passend to a PSPDFRenderQueue in order to fulfill the task.

    To create a new render request you usually create a PSPDFMutableRenderRequest and set the properties you need.

    Thread safety

    PSPDFRenderRequest is not thread safe, you should never modify a mutable render request from multiple threads nor should you modify a mutable render request while reading data from it on a different thread.

    As soon as you hand over ownership of a render request to the render engine, it is copied, so that you do not need to worry about thread safety between your render requests and the ones the render engine holds.

    See

    PSPDFRenderTask

    See

    PSPDFMutableRenderRequest
    See more

    Declaration

    Objective-C

    
    @interface PSPDFRenderRequest : NSObject <NSCopying, NSMutableCopying>

    Swift

    class PSPDFRenderRequest : NSObject, NSCopying, NSMutableCopying
  • A render task is used to create an image from the page (or part of it) of a document.

    Depending on the PSPDFRenderRequest cache policy, a render task checks the cache before actually triggering a new rendering.

    You create a render task by passing it an instance of PSPDFRenderRequest. Once you have created a render request make sure to fully set it up before scheduling it in a render queue.

    A simple example of requesting an image from a page:

    PSPDFMutableRenderRequest *request = [[PSPDFMutableRenderRequest alloc] initWithDocument:document];
    request.pageIndex = pageIndex;
    request.imageSize = CGSizeMake(320.0f, 480.0f);
    
    PSPDFRenderTask *task = [[PSPDFRenderTask alloc] initWithRequest:request];
    task.priority = PSPDFRenderQueuePriorityUtility;
    task.delegate = self;
    
    [PSPDFKit.sharedInstance.renderManager.renderQueue scheduleTask:task];
    
    let request = PSPDFMutableRenderRequest(document: document)
    request.pageIndex = 0
    request.imageSize = CGSize(width: 320.0, height: 480.0)
    
    let task = PSPDFRenderTask(request: request)!
    task.priority = .utility
    task.delegate = self
    
    PSPDFKit.sharedInstance.renderManager.renderQueue.schedule(task)
    
    See more

    Declaration

    Objective-C

    
    @interface PSPDFRenderTask : NSObject

    Swift

    class PSPDFRenderTask : NSObject
  • A checkpointer handles autosaving of annotations for recovery in case of a crash that occurs without saving. A checkpoint is a small file that contains all the changes made to the document that haven’t been saved. The checkpoint is created according to the strategy. On a save of the document, it is automatically deleted.

    Note

    Checkpoints are not supported for multi-provider PSPDFDocuments, or documents that are encrypted.

    Note

    This class is thread safe.

    Note

    You must not create instances of this class yourself, and instead use the checkpointer property on PSPDFDocument.
    See more

    Declaration

    Objective-C

    
    @interface PSPDFDocumentCheckpointer : NSObject

    Swift

    class PSPDFDocumentCheckpointer : NSObject
  • This class handles opening URLs for other applications and coordinates access to the network indicator manager since this is restricted in an iOS extension case.

    See more

    Declaration

    Objective-C

    @protocol PSPDFApplication <NSObject>

    Swift

    protocol PSPDFApplication : NSObjectProtocol
  • Undocumented

    See more

    Declaration

    Objective-C

    @protocol PSPDFErrorHandler<NSObject>
    
    /// All parameters are optional, however you should call it with at least error or title.
    ///
    /// @note The implementing view controller can decide how to best present this.
    - (void)handleError:(nullable NSError *)error title:(nullable NSString *)title message:(nullable NSString *)message;
    
    @end

    Swift

    protocol PSPDFErrorHandler : NSObjectProtocol
  • Undocumented

    See more

    Declaration

    Objective-C

    @protocol PSPDFExternalURLHandler<NSObject>
    
    /// Handles URL, shows alert dialog if this would open an external app.
    /// Returns NO if this is an internal URL (http[s]://, file://)
    - (BOOL)handleExternalURL:(nonnull NSURL *)URL completionBlock:(nullable void (^)(BOOL switchedApplication))completionBlock;
    
    @end

    Swift

    protocol PSPDFExternalURLHandler : NSObjectProtocol
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface PSPDFSelectionState : NSObject<NSSecureCoding>
    
    /// Returns an instance of the receiver configured to match the selectionView argument's state, if a selection exists.
    + (nullable instancetype)stateForSelectionView:(PSPDFTextSelectionView *)selectionView;
    
    /// The uid of the document which the receiver corresponds to.
    @property (nonatomic, readonly) NSString *UID;
    
    /// The page index on which the selection exists.
    @property (nonatomic, readonly) PSPDFPageIndex selectionPageIndex;
    
    /**
     The range of glyphs (in `PSPDFTextParser.glyphs`) that are selected.
     If no glyphs are selected, this method returns `PSPDFInvalidGlyphRange`.
     */
    @property (nonatomic, readonly) NSRange selectedGlyphRange;
    
    /// The info for the selected image, if any.
    @property (nonatomic, readonly, nullable) PSPDFImageInfo *selectedImage;
    
    /**
     Returns a Boolean value that indicates whether a selection state is equal to the receiver.
    
     @param selectionState The selection with which to compare the receiver
     @return YES is `selectionState` is equivalent to the receiver, otherwise NO.
     */
    - (BOOL)isEqualToSelectionState:(nullable PSPDFSelectionState *)selectionState;
    
    @end

    Swift

    class PSPDFSelectionState : NSObject, NSSecureCoding
  • Represents a certain view state (document position, zoom) of a PSPDFDocument.

    Note

    Prior to PSPDFKit 8 for iOS, if an instance of this class had a viewPort, that view port was defined in raw PDF coordinates (not considering page rotation or CropBox). The view port is now defined in normalized PDF coordinates. Instances created from old archives may contain unexpected view ports, but PSPDFKit will automatically apply the page transform when such an instance is applied to a view.
    See more

    Declaration

    Objective-C

    
    @interface PSPDFViewState : PSPDFModel <NSSecureCoding>

    Swift

    class PSPDFViewState : PSPDFModel, NSSecureCoding