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/current/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 Variant that may be used to set options. These can also later be changed via subscripting access.
Declaration
Objective-C
+ (void)setLicenseKey:(nonnull 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;
-
The PDF render coordinator.
Declaration
Objective-C
@property (nonatomic, readonly) id<PSPDFRenderManager> _Nonnull renderManager;
-
The annotation style manager.
Declaration
Objective-C
@property (nonatomic, readonly) id<PSPDFAnnotationStyleManager> _Nonnull styleManager;
-
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;
-
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;
-
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
-
Loads images from the PSPDFKit.bundle.
Note
CallsimageLoadingHandler
if one is set, else falls back to internal loading logic.Declaration
Objective-C
+ (nullable NSImage *)imageNamed:(nonnull NSString *)name;
Swift
class func imageNamed(_ name: String) -> NSImage?
-
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.Declaration
Objective-C
@property (null_resettable) NSImage *_Nullable (^)(NSString *_Nonnull) imageLoadingHandler;
Swift
var imageLoadingHandler: ((String) -> NSImage?)! { get set }
-
Set the global PSPDFKit log level. Defaults to
PSPDFLogLevelMaskInfo|PSPDFLogLevelMaskWarning|PSPDFLogLevelMaskError|PSPDFLogLevelMaskCritical
.Warning
Setting this toPSPDFLogLevelMaskVerbose
will severely slow down your application.Declaration
Objective-C
@property (nonatomic) PSPDFLogLevelMask logLevel;
Swift
var logLevel: LogLevelMask { get set }
-
Custom log handler to forward logging to a different system.
PSPDFKit uses
os_log
or falls back toNSLog
on older OS versions. Setting this to NULL will reset the default behavior.Note
Usage example:[PSPDFKitGlobal.sharedInstance setLogHandler:^(PSPDFLogLevelMask type, 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 (^)(PSPDFLogLevelMask, const char *_Nullable, __attribute__((noescape)) NSString *_Nonnull (^_Nonnull)(void), const char *_Nullable, const char *_Nullable, NSUInteger) logHandler;
-
Custom log handler to forward logging to a different system.
PSPDFKit uses
os_log
Setting this to NULL will reset the default behavior.@note Usage example:
SDK.shared.setLogHandler { (level: PSPDFLogLevelMask, tag: String, message: @escaping () -> String, file: String, function: String, line: Int) in print("PSPDFKit says from \(function): \(message())") }
Declaration
Swift
public func setLogHandler(handler: @escaping (_ level: LogLevelMask, _ tag: String, _ message: @escaping () -> String, _ file: String, _ function: String, _ line: Int) -> Void)