PSPDFKitGlobal
Objective-C
@interface PSPDFKitGlobal : NSObject
Swift
class SDK : NSObject
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:
and valueForKey:
or the subscripted variants to set/get properties.
Subclassing notes:
In PSPDFKit various classes can be subclassed and registered as subclasses via
overrideClass:withClass:
on Document
(model) and PDFConfiguration
(view/controller).
See https://pspdfkit.com/guides/ios/getting-started/overriding-classes/ for details.
-
The shared PSPDFKit configuration instance.
Note
This is the default instance used in document and pdf controller instances.Declaration
Objective-C
@property (class, readonly) NS_SWIFT_NAME(shared) PSPDFKitGlobal *sharedInstance;
Swift
class var shared: SDK { get }
-
Activate PSPDFKit with your license key from https://customers.pspdfkit.com
Declaration
Objective-C
+ (void)setLicenseKey:(nonnull NSString *)licenseKey;
Swift
class func setLicenseKey(_ licenseKey: String)
-
Activate PSPDFKit with your license key from https://customers.pspdfkit.com
This can also be used for passing options when trialing PSPDFKit. Simply pass
nil
as thelicenseKey
.Variant that may be used to set options. These can also later be changed via subscripting access.
Declaration
Objective-C
+ (void)setLicenseKey:(nullable NSString *)licenseKey options:(nullable NSDictionary<PSPDFSettingKey, id> *)options;
Swift
class func setLicenseKey(_ licenseKey: String?, options: [SDK.Setting : Any]? = nil)
-
Returns the full PSPDFKit product version string (e.g. “PSPDFKit 9.0.0 for iOS (90000)”)
Declaration
Objective-C
@property (class, readonly) NSString *_Nonnull versionString;
Swift
class var versionString: String { get }
-
Returns just the framework version. (e.g. 9.0.0)
Declaration
Objective-C
@property (class, readonly) NSString *_Nonnull versionNumber;
Swift
class var versionNumber: String { get }
-
Returns the PSPDFKit version date.
Declaration
Objective-C
@property (class, readonly) NSDate *_Nonnull compiledAt;
Swift
class var compiledAt: Date { get }
-
The internal build number. Increments with every version.
Declaration
Objective-C
@property (class, readonly) NSUInteger buildNumber;
Swift
class var buildNumber: UInt { get }
-
Checks if any of the specified features are enabled.
Declaration
Objective-C
+ (BOOL)isFeatureEnabled:(PSPDFFeatureMask)feature;
Swift
class func isFeatureEnabled(_ feature: Features) -> Bool
Parameters
feature
A bitmask of features, which may be combined with the bitwise or operator (|).
Return Value
YES if any of the features in the passed in bitmask are enabled. NO if all of the features are not enabled.
-
Allow generic array access.
Declaration
Objective-C
- (nullable id)objectForKeyedSubscript:(nonnull PSPDFSettingKey)key;
Swift
subscript(key: SDK.Setting) -> Any? { get set }
-
Shortcut that returns booleans.
Declaration
Objective-C
- (BOOL)boolForKey:(nonnull PSPDFSettingKey)key;
Swift
func bool(forKey key: SDK.Setting) -> Bool
-
Allow direct dictionary-like access.
Declaration
Objective-C
- (void)setObject:(nullable id)object forKeyedSubscript:(nonnull PSPDFSettingKey)key;
-
The shared memory/file cache.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFCache *_Nonnull cache;
Swift
var cache: PSPDFCache { get }
-
The common file manager object.
Declaration
Objective-C
@property (nonatomic, readonly) id<PSPDFFileManager> _Nonnull fileManager;
Swift
var fileManager: FileManagerProtocol { get }
-
The PDF render coordinator.
Declaration
Objective-C
@property (nonatomic, readonly) id<PSPDFRenderManager> _Nonnull renderManager;
Swift
var renderManager: RenderManager { get }
-
The annotation style manager.
Declaration
Objective-C
@property (nonatomic, readonly) id<PSPDFAnnotationStyleManager> _Nonnull styleManager;
Swift
var styleManager: AnnotationStyleManager { get }
-
The shared signature handler for digital signature management.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFSignatureManager *_Nonnull signatureManager;
Swift
var signatureManager: PSPDFSignatureManager { get }
-
Controls various security-related aspects and allows enabling/disabling features based on the security settings.
Declaration
Objective-C
@property (nonatomic, readonly) id<PSPDFApplicationPolicy> _Nonnull policy;
Swift
var policy: ApplicationPolicy { get }
-
The default library. You can override this property to use a custom
PSPDFLibrary
as the default library. It is recommended that you do this early in your application launch. Defaults to an unencrypted library by default or tonil
if the FTS feature is not enabled in the license.If you want to change the indexing priority of the library, set the
PSPDFSettingKeyLibraryIndexingPriority
in the options dictionary passed into+[PSPDFKitGlobal setLicenseKey:options:]
.Declaration
Objective-C
@property (nullable) PSPDFLibrary *library;
Swift
var library: PSPDFLibrary? { get set }
-
An encryption provider for databases. Defaults to
nil
. You must set this property before using any database encryption features. SeePSPDFDatabaseEncryptionProvider
for more information on how to implement this.Declaration
Objective-C
@property (nullable) id<PSPDFDatabaseEncryptionProvider> databaseEncryptionProvider;
Swift
var databaseEncryptionProvider: DatabaseEncryptionProvider? { get set }
-
Various PSPDFKit objects require dependencies. Use this helper to automatically connect them. Will only set known objects that are not already set.
@returns Number of properties updated.
Declaration
Objective-C
- (NSInteger)injectDependentProperties:(nonnull id)object;
Swift
func injectDependentProperties(_ object: Any) -> Int
-
PSPDFKit analytics instance. All PSPDFKit events are logged with this instance.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFAnalytics *_Nonnull analytics;
Swift
var analytics: PSPDFAnalytics { get }
-
Exposes application services.
Declaration
Objective-C
@property (nonatomic) id<PSPDFApplication> _Nonnull application;
Swift
var application: Application { get set }
-
The global speech controller object.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFSpeechController *_Nonnull speechController;
Swift
var speechController: PSPDFSpeechController { get }
-
The Apple Pencil manager. Lazily loaded.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFApplePencilManager *_Nonnull applePencilManager;
Swift
var applePencilManager: PSPDFApplePencilManager { get }
-
The screen controller can be used to mirror content from a visible
PDFViewController
. SeepdfControllerToMirror
to start the mirroring process.Declaration
Objective-C
@property (nonatomic, readonly) PSPDFScreenController *_Nonnull screenController;
Swift
var screenController: PSPDFScreenController { get }
-
Controls screen idle timing.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFBrightnessManager *_Nonnull brightnessManager;
Swift
var brightnessManager: PSPDFBrightnessManager { get }
-
Loads images from the PSPDFKit.bundle.
Note
CallsimageLoadingHandler
if one is set, else falls back to internal loading logic. -
Register a custom block to return custom images. If this block is NULL or returns nil, PSPDFKit.bundle will use for the lookup. If your custom handler returns no image, the default lookup will be used as well.
Note
Images are cached, so don’t return different images for the sameimageName
during an app session. This was exposed asPSPDFSetBundleImageBlock
in earlier versions.
-
The global log level for PSPDFKit. Default:
.info
.Setting a log level implies enabling all log levels with higher severity. For example, setting
.warning
also enables logging of messages with the level.error
or.critical
.See the documentation of
LogLevel
to learn more about individual log levels and how to view them in Xcode, in the Console app or in the Terminal.Warning
Setting the log level to.debug
or.verbose
will have a significant performance impact on your app.Declaration
Objective-C
@property (nonatomic) PSPDFLogLevel logLevel;
Swift
var logLevel: LogLevel { get set }
-
The custom log handler that can be used to forward logging to a different service. Setting this to
nil
will reset the default behavior.By default, PSPDFKit uses
os_log
to send logs to the operating system. You can override this behavior and use your own logging service instead of or in addition toos_log
.[PSPDFKitGlobal.sharedInstance setLogHandler:^(PSPDFLogLevel level, const char *tag, NSString * (^message)(void), const char *file, const char *function, NSUInteger line) { NSLog(@"PSPDFKit says from %s: %@", function, message()); }];
Declaration
Objective-C
@property (nonatomic, null_resettable) void (^)(PSPDFLogLevel, const char *_Nullable, __attribute__((noescape)) NSString *_Nonnull (^_Nonnull)(void), const char *_Nullable, const char *_Nullable, NSUInteger) logHandler;
-
The custom log handler that can be used to forward logging to a different service.
By default, PSPDFKit uses
OSLog
to send logs to the operating system. You can override this behavior and use your own logging service instead of or in addition toOSLog
.PSPDFKit.SDK.shared.setLogHandler { _, _, message, _, function, _ in print("PSPDFKit says from \(function): \(message())") }
Declaration
Swift
public func setLogHandler(_ handler: @escaping (_ level: LogLevel, _ tag: String, _ message: () -> String, _ file: String, _ function: String, _ line: UInt) -> Void)
-
Reset the log handler to its default behavior.
Declaration
Swift
public func resetLogHandler()