Common
-
Annotates a class that can be overridden with a more specific subclass.
Declaration
Objective-C
@protocol PSPDFOverridable <NSObject>
Swift
protocol Overridable : NSObjectProtocol
-
Declaration
Objective-C
@interface PSPDFBaseConfiguration< BuilderType : __kindof PSPDFBaseConfigurationBuilder *> : PSPDFModel
Swift
class BaseConfiguration<BuilderType> : ModelObject where BuilderType : BaseConfigurationBuilder
-
PSPDFKit - The Leading PDF Framework for iOS, Android and the Web. This is the configuration object for framework-global settings.
Note
The PSPDFKit shared object is a global, thread-safe key/value store. UsesetValue:forKey:
andvalueForKey:
or the subscripted variants to set/get properties.Subclassing notes: In PSPDFKit various classes can be subclassed and registered as subclasses via
See moreoverrideClass:withClass:
onDocument
(model) andPDFConfiguration
(view/controller). See https://pspdfkit.com/guides/ios/getting-started/overriding-classes/ for details.Declaration
Objective-C
@interface PSPDFKitGlobal : NSObject
Swift
class SDK : NSObject
-
An angle a PDF page is displayed at in clockwise degrees.
See moreDeclaration
Objective-C
enum PSPDFRotation : NSUInteger {}
Swift
@frozen enum Rotation : UInt, @unchecked Sendable
-
The
Document
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
DataProviding
protocol). The typical use case is to initialize the document with a singlefileURL
, which creates an implicitPSPDFCoordinatedFileDataProvider
by default. You can also opt to useData
or custom implementations ofDataProviding
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
ortitle
. 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.Document
supportsNSFastEnumeration
by enumerating over itsdocumentProviders
. The document providers are internal wrappers around the data providers created during initialization.Calling
copy()
on a subclass ofDocument
will return an instance ofDocument
, not the subclass. The copy will not attempt to load from a checkpoint.Note
Not all state is archived with
NSCoder
.Note
Ensure that a
Document
is only opened by onePDFViewController
at any time. Also ensure that subclasses do not implement their own equality semantics, and instead use theUID
property to check if two documents are equal.Declaration
Objective-C
@interface PSPDFDocument : NSObject <PSPDFDocumentProviderDelegate, PSPDFOverridable, NSCopying, NSSecureCoding, NSFastEnumeration, PSPDFFileCoordinationDelegate>
extension Document: ObservableObject
Swift
class Document : NSObject, DocumentProviderDelegate, Overridable, NSCopying, NSSecureCoding, NSFastEnumeration, FileCoordinationDelegate
-
A
Document
consists of one or multiplePSPDFDocumentProvider
‘s. Each document provider has exactly one data source (file/data/dataProvider)Note
This class is used withinDocument
and should not be instantiated externally.Declaration
Objective-C
@interface PSPDFDocumentProvider : NSObject <PSPDFOverridable>
Swift
class PDFDocumentProvider : NSObject, Overridable
-
Delegate for writing annotations.
See moreDeclaration
Objective-C
@protocol PSPDFDocumentProviderDelegate <NSObject>
Swift
protocol DocumentProviderDelegate : 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 specifyingPSPDFDocumentPermissions
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 passnil
for security options.Declaration
Objective-C
@interface PSPDFDocumentSecurityOptions : NSObject
Swift
class SecurityOptions : 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
Document
‘sfeatures
property. So if you, for example, want to check if a document can be modified, you can checkdocument.features.canModify
.See
-[PSPDFDocument features]
Threading
See morePSPDFDocumentFeatures
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.Declaration
Objective-C
@interface PSPDFDocumentFeatures : NSObject <PSPDFDocumentFeaturesSource>
Swift
class PDFDocumentFeatures : NSObject, PDFDocumentFeaturesSource
-
A
Document
subclass that can be used to display and annotate image files. Can handle JPEG, PNG and TIFF 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.
See https://pspdfkit.com/guides/ios/annotations/annotate-images/ for more information.
Note
PSPDFImageDocument
requires the Image Documents feature to be enabled for your license to work.Declaration
Objective-C
@interface PSPDFImageDocument : PSPDFDocument
Swift
class ImageDocument : Document
-
Declares all possible feature flags in a license.
See moreDeclaration
Objective-C
enum PSPDFFeatureMask : NSUInteger {}
Swift
struct Features : OptionSet, @unchecked Sendable
-
Wraps file system calls. Internal class cluster. Can be replaced with Enterprise SDK wrappers like Good Technology or MobileIron AppConnect.
See moreDeclaration
Objective-C
@protocol PSPDFFileManager <NSObject>
Swift
protocol FileManagerProtocol : NSObjectProtocol
-
Coordinates file presenters and notifications. Observed presenters are automatically unregistered in response to
See moreUIApplicationDidEnterBackgroundNotification
notification.Declaration
Objective-C
@interface PSPDFFilePresenterCoordinator : NSObject
Swift
class FilePresenterCoordinator : NSObject
-
Undocumented
See moreDeclaration
Objective-C
NS_CLOSED_ENUM(NSInteger, PSPDFPageBinding) { PSPDFPageBindingUnknown, PSPDFPageBindingLeftEdge, PSPDFPageBindingRightEdge, }
Swift
@frozen enum PSPDFPageBinding : Int, @unchecked Sendable
-
Represents PDF page data. Managed within
See morePSPDFDocumentProvider
.Declaration
Objective-C
@interface PSPDFPageInfo : NSObject <NSCopying, NSSecureCoding>
Swift
class PDFPageInfo : NSObject, NSCopying, NSSecureCoding
-
The PDF render manager coordinates the PDF renderer used.
See moreDeclaration
Objective-C
@protocol PSPDFRenderManager <NSObject>
Swift
protocol RenderManager : NSObjectProtocol
-
Defines the options to apply when rendering PDF pages, such as color inversion, filters, colors and annotation behavior.
See moreDeclaration
Objective-C
@interface PSPDFRenderOptions : PSPDFModel
Swift
class RenderOptions : ModelObject
-
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 moreDeclaration
Objective-C
@interface PSPDFRenderQueue : NSObject
Swift
class RenderQueue : 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 passed to aPSPDFRenderQueue
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
PSPDFRenderTaskSee
PSPDFMutableRenderRequestDeclaration
Objective-C
@interface PSPDFRenderRequest : NSObject <NSCopying, NSMutableCopying>
Swift
class RenderRequest : 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:
See morelet request = MutableRenderRequest(document: document) request.pageIndex = 0 request.imageSize = CGSize(width: 320.0, height: 480.0) let task = try RenderTask(request: request) task.priority = .utility task.delegate = self SDK.shared.renderManager.renderQueue.schedule(task)
Declaration
Objective-C
@interface PSPDFRenderTask : NSObject
Swift
class RenderTask : 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-providerDocument
s, or documents that are encrypted.Note
This class is thread safe.Note
You must not create instances of this class yourself, and instead use thecheckpointer
property onDocument
.Declaration
Objective-C
@interface PSPDFDocumentCheckpointer : NSObject
Swift
class DocumentCheckpointer : NSObject
-
Represents a possible destination directory.
See more -
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 moreDeclaration
Objective-C
@protocol PSPDFApplication <NSObject>
Swift
protocol Application : NSObjectProtocol
-
A
See morePDFConfiguration
defines the behavior of aPDFViewController
. It uses the builder pattern viaPDFConfigurationBuilder
to create an immutable copy via a block.Declaration
Objective-C
@interface PSPDFConfiguration : PSPDFBaseConfiguration <PSPDFConfigurationBuilder *> <PSPDFOverridable>
Swift
class PDFConfiguration : BaseConfiguration<PDFConfigurationBuilder>, Overridable
-
Protocol handling various controls.
Declaration
Objective-C
@protocol PSPDFControlDelegate <PSPDFPresentationActions, PSPDFPageControls, PSPDFUserInterfaceControls, PSPDFErrorHandler>
Swift
protocol ControlDelegate : ErrorHandler, PageControls, PresentationActions, UserInterfaceControls
-
Undocumented
See moreDeclaration
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 ErrorHandler : NSObjectProtocol
-
Undocumented
See moreDeclaration
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 ExternalURLHandler : NSObjectProtocol
-
The presentation context is used to provide several parts of the framework with information about what is currently presented in the corresponding
PDFViewController
.Note
You should never implementPSPDFPresentationContext
yourself, instead it is created by the framework and handed to you in several places when needed.Declaration
Objective-C
@protocol PSPDFPresentationContext < PSPDFOverridable, PSPDFVisiblePagesDataSource, PSPDFErrorHandler>
Swift
protocol PresentationContext : ErrorHandler, Overridable, VisiblePagesDataSource
-
Contains information about the currently selected state on a page.
See moreDeclaration
Objective-C
@interface PSPDFSelectionState : NSObject <NSSecureCoding>
Swift
class SelectionState : NSObject, NSSecureCoding
-
Represents a certain view state (document position, zoom) of a
Document
.Note
Prior to PSPDFKit 8 for iOS, if an instance of this class had aviewPort
, that viewport was defined in raw PDF coordinates (not considering page rotation or CropBox). The viewport is now defined in normalized PDF coordinates. Instances created from old archives may contain unexpected viewports, but PSPDFKit will automatically apply the page transform when such an instance is applied to a view.Declaration
Objective-C
@interface PSPDFViewState : PSPDFModel
Swift
class PDFViewState : ModelObject